From 1a36fce4c2304d87a6f49ba3ec580819b15a2722 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 14 Oct 2015 17:36:03 -0700 Subject: [PATCH 01/10] JavaScript LS scaffolding + JS module inference --- lib/lib.core.d.ts | 16 + lib/lib.core.es6.d.ts | 16 + lib/lib.d.ts | 16 + lib/lib.es6.d.ts | 16 + lib/tsc.js | 1 + src/compiler/binder.ts | 65 ++- src/compiler/checker.ts | 83 +++- src/compiler/core.ts | 7 +- src/compiler/parser.ts | 17 +- src/compiler/program.ts | 25 +- src/compiler/types.ts | 7 +- src/compiler/utilities.ts | 60 ++- src/harness/fourslash.ts | 32 +- src/harness/harness.ts | 2 +- src/harness/harnessLanguageService.ts | 2 +- src/lib/core.d.ts | 16 + src/server/editorServices.ts | 9 +- src/services/services.ts | 402 +++++++++++------- src/services/shims.ts | 3 +- src/services/signatureHelp.ts | 2 +- .../getJavaScriptSyntacticDiagnostics1.ts | 19 - tests/cases/fourslash/javaScriptModules12.ts | 57 +++ tests/cases/fourslash/javaScriptModules13.ts | 29 ++ tests/cases/fourslash/javaScriptModules14.ts | 28 ++ tests/cases/fourslash/javaScriptModules15.ts | 27 ++ tests/cases/fourslash/javaScriptModules16.ts | 22 + tests/cases/fourslash/javaScriptModules17.ts | 18 + tests/cases/fourslash/javaScriptModules18.ts | 14 + tests/cases/unittests/moduleResolution.ts | 28 +- .../unittests/services/preProcessFile.ts | 149 ++++++- tests/webTestServer.ts | 15 +- 31 files changed, 968 insertions(+), 235 deletions(-) delete mode 100644 tests/cases/fourslash/getJavaScriptSyntacticDiagnostics1.ts create mode 100644 tests/cases/fourslash/javaScriptModules12.ts create mode 100644 tests/cases/fourslash/javaScriptModules13.ts create mode 100644 tests/cases/fourslash/javaScriptModules14.ts create mode 100644 tests/cases/fourslash/javaScriptModules15.ts create mode 100644 tests/cases/fourslash/javaScriptModules16.ts create mode 100644 tests/cases/fourslash/javaScriptModules17.ts create mode 100644 tests/cases/fourslash/javaScriptModules18.ts diff --git a/lib/lib.core.d.ts b/lib/lib.core.d.ts index b588c9fdb77ee..c1a71dd8d1da8 100644 --- a/lib/lib.core.d.ts +++ b/lib/lib.core.d.ts @@ -1198,6 +1198,22 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } + +declare namespace CommonJS { + export var require: Require; + + export var exports: any; + + interface Exports { } + interface Module { + exports: Exports; + } + + interface Require { + (moduleName: string): any; + } +} + interface ArrayLike { length: number; [n: number]: T; diff --git a/lib/lib.core.es6.d.ts b/lib/lib.core.es6.d.ts index fd115497f8a2b..b0d4120b4b96e 100644 --- a/lib/lib.core.es6.d.ts +++ b/lib/lib.core.es6.d.ts @@ -1198,6 +1198,22 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } + +declare namespace CommonJS { + export var require: Require; + + export var exports: any; + + interface Exports { } + interface Module { + exports: Exports; + } + + interface Require { + (moduleName: string): any; + } +} + interface ArrayLike { length: number; [n: number]: T; diff --git a/lib/lib.d.ts b/lib/lib.d.ts index a65fc96e43fa0..450f79b36e9ea 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -1198,6 +1198,22 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } + +declare namespace CommonJS { + export var require: Require; + + export var exports: any; + + interface Exports { } + interface Module { + exports: Exports; + } + + interface Require { + (moduleName: string): any; + } +} + interface ArrayLike { length: number; [n: number]: T; diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index 75ba647a1284e..63e6a101fbc6e 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -1198,6 +1198,22 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } + +declare namespace CommonJS { + export var require: Require; + + export var exports: any; + + interface Exports { } + interface Module { + exports: Exports; + } + + interface Require { + (moduleName: string): any; + } +} + interface ArrayLike { length: number; [n: number]: T; diff --git a/lib/tsc.js b/lib/tsc.js index 3d2b7f3956a18..a4c2586f0418d 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -650,6 +650,7 @@ var ts; } ts.fileExtensionIs = fileExtensionIs; ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; + ts.supportedJsExtensions = ts.supportedExtensions.concat(".js", ".jsx"); var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index c12a9afad62ae..4e0d5225f58ed 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -6,8 +6,8 @@ namespace ts { export const enum ModuleInstanceState { NonInstantiated = 0, - Instantiated = 1, - ConstEnumOnly = 2 + Instantiated = 1, + ConstEnumOnly = 2 } export function getModuleInstanceState(node: Node): ModuleInstanceState { @@ -90,6 +90,8 @@ namespace ts { let lastContainer: Node; let seenThisKeyword: boolean; + let isJavaScriptFile = isSourceFileJavaScript(file); + // If this file is an external module, then it is automatically in strict-mode according to // ES6. If it is not an external module, then we'll determine if it is in strict mode or // not depending on if we see "use strict" in certain places (or if we hit a class/namespace). @@ -167,6 +169,10 @@ namespace ts { case SyntaxKind.FunctionDeclaration: case SyntaxKind.ClassDeclaration: return node.flags & NodeFlags.Default ? "default" : undefined; + + case SyntaxKind.BinaryExpression: + Debug.assert(isModuleExportsAssignment(node)); + return "__jsExports"; } } @@ -779,7 +785,7 @@ namespace ts { return "__" + indexOf((node.parent).parameters, node); } - function bind(node: Node) { + function bind(node: Node): void { node.parent = parent; let savedInStrictMode = inStrictMode; @@ -851,9 +857,18 @@ namespace ts { function bindWorker(node: Node) { switch (node.kind) { + /* Strict mode checks */ case SyntaxKind.Identifier: return checkStrictModeIdentifier(node); case SyntaxKind.BinaryExpression: + if (isJavaScriptFile) { + if (isExportsPropertyAssignment(node)) { + bindExportsPropertyAssignment(node); + } + else if (isModuleExportsAssignment(node)) { + bindModuleExportsAssignment(node); + } + } return checkStrictModeBinaryExpression(node); case SyntaxKind.CatchClause: return checkStrictModeCatchClause(node); @@ -919,6 +934,16 @@ namespace ts { checkStrictModeFunctionName(node); let bindingName = (node).name ? (node).name.text : "__function"; return bindAnonymousDeclaration(node, SymbolFlags.Function, bindingName); + + case SyntaxKind.CallExpression: + // We're only inspecting call expressions to detect CommonJS modules, so we can skip + // this check if we've already seen the module indicator + if (isJavaScriptFile && !file.commonJsModuleIndicator) { + bindCallExpression(node); + } + break; + + // Members of classes, interfaces, and modules case SyntaxKind.ClassExpression: case SyntaxKind.ClassDeclaration: return bindClassLikeDeclaration(node); @@ -930,6 +955,8 @@ namespace ts { return bindEnumDeclaration(node); case SyntaxKind.ModuleDeclaration: return bindModuleDeclaration(node); + + // Imports and exports case SyntaxKind.ImportEqualsDeclaration: case SyntaxKind.NamespaceImport: case SyntaxKind.ImportSpecifier: @@ -949,10 +976,14 @@ namespace ts { function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (isExternalModule(file)) { - bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName)}"`); + bindSourceFileAsExternalModule(); } } + function bindSourceFileAsExternalModule() { + bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName) }"`); + } + function bindExportAssignment(node: ExportAssignment) { if (!container.symbol || !container.symbol.exports) { // Export assignment in some sort of block construct @@ -985,6 +1016,32 @@ namespace ts { } } + function setCommonJsModuleIndicator(node: Node) { + if (!file.commonJsModuleIndicator) { + file.commonJsModuleIndicator = node; + bindSourceFileAsExternalModule(); + } + } + + function bindExportsPropertyAssignment(node: BinaryExpression) { + // When we create a property via 'exports.foo = bar', the 'exports.foo' property access + // expression is the declaration + setCommonJsModuleIndicator(node); + declareSymbol(file.symbol.exports, file.symbol, node.left, SymbolFlags.Property | SymbolFlags.Export, SymbolFlags.None); + } + + function bindModuleExportsAssignment(node: BinaryExpression) { + // 'module.exports = expr' assignment + setCommonJsModuleIndicator(node); + declareSymbol(file.symbol.exports, file.symbol, node, SymbolFlags.None, SymbolFlags.None); + } + + function bindCallExpression(node: CallExpression) { + if (isRequireCall(node)) { + setCommonJsModuleIndicator(node); + } + } + function bindClassLikeDeclaration(node: ClassLikeDeclaration) { if (node.kind === SyntaxKind.ClassDeclaration) { bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b13520cee2dde..7e15f0a3ad033 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -160,6 +160,8 @@ namespace ts { let getGlobalPromiseConstructorLikeType: () => ObjectType; let getGlobalThenableType: () => ObjectType; + let cjsRequireType: Type; + let tupleTypes: Map = {}; let unionTypes: Map = {}; let intersectionTypes: Map = {}; @@ -362,7 +364,7 @@ namespace ts { } function isGlobalSourceFile(node: Node) { - return node.kind === SyntaxKind.SourceFile && !isExternalModule(node); + return node.kind === SyntaxKind.SourceFile && !isExternalOrCommonJsModule(node); } function getSymbol(symbols: SymbolTable, name: string, meaning: SymbolFlags): Symbol { @@ -478,7 +480,7 @@ namespace ts { } switch (location.kind) { case SyntaxKind.SourceFile: - if (!isExternalModule(location)) break; + if (!isExternalOrCommonJsModule(location)) break; case SyntaxKind.ModuleDeclaration: let moduleExports = getSymbolOfNode(location).exports; if (location.kind === SyntaxKind.SourceFile || @@ -993,6 +995,11 @@ namespace ts { if (moduleName === undefined) { return; } + + if (moduleName.indexOf("!") >= 0) { + moduleName = moduleName.substr(0, moduleName.indexOf("!")); + } + let isRelative = isExternalModuleNameRelative(moduleName); if (!isRelative) { let symbol = getSymbol(globals, "\"" + moduleName + "\"", SymbolFlags.ValueModule); @@ -1080,6 +1087,20 @@ namespace ts { visit(resolveExternalModuleName(node, (node).moduleSpecifier)); } } + + // CommonJS 'module.exports = expr' assignments + let commonJsModuleExports = symbol.exports["__jsExports"]; + if (commonJsModuleExports) { + for (var i = 0; i < commonJsModuleExports.declarations.length; i++) { + let properties = getPropertiesOfType(checkExpression((commonJsModuleExports.declarations[i]).right)); + if (i === 0) { + result = createSymbolTable(properties); + } + else { + mergeSymbolTable(result, createSymbolTable(properties)); + } + } + } } } } @@ -1203,7 +1224,7 @@ namespace ts { } switch (location.kind) { case SyntaxKind.SourceFile: - if (!isExternalModule(location)) { + if (!isExternalOrCommonJsModule(location)) { break; } case SyntaxKind.ModuleDeclaration: @@ -1385,7 +1406,7 @@ namespace ts { function hasExternalModuleSymbol(declaration: Node) { return (declaration.kind === SyntaxKind.ModuleDeclaration && (declaration).name.kind === SyntaxKind.StringLiteral) || - (declaration.kind === SyntaxKind.SourceFile && isExternalModule(declaration)); + (declaration.kind === SyntaxKind.SourceFile && isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol: Symbol): SymbolVisibilityResult { @@ -2059,7 +2080,7 @@ namespace ts { } } else if (node.kind === SyntaxKind.SourceFile) { - return isExternalModule(node) ? node : undefined; + return isExternalOrCommonJsModule(node) ? node : undefined; } } Debug.fail("getContainingModule cant reach here"); @@ -2180,7 +2201,7 @@ namespace ts { case SyntaxKind.SourceFile: return true; - // Export assignements do not create name bindings outside the module + // Export assignments do not create name bindings outside the module case SyntaxKind.ExportAssignment: return false; @@ -2565,6 +2586,10 @@ namespace ts { if (declaration.kind === SyntaxKind.ExportAssignment) { return links.type = checkExpression((declaration).expression); } + // Handle exports.p = expr + if (declaration.kind === SyntaxKind.PropertyAccessExpression && declaration.parent.kind === SyntaxKind.BinaryExpression) { + return checkExpressionCached((declaration.parent).right); + } // Handle variable, parameter or property if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) { return unknownType; @@ -3811,6 +3836,18 @@ namespace ts { return result; } + function resolveExternalModuleTypeByLiteral(name: StringLiteral) { + let moduleSym = resolveExternalModuleName(name, name); + if (moduleSym) { + let moduleSymSym = resolveExternalModuleSymbol(moduleSym); + if (moduleSymSym) { + return getTypeOfSymbol(moduleSymSym); + } + } + + return anyType; + } + function getReturnTypeOfSignature(signature: Signature): Type { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, TypeSystemPropertyName.ResolvedReturnType)) { @@ -4174,11 +4211,15 @@ namespace ts { * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type */ function getExportedTypeFromNamespace(namespace: string, name: string): Type { - let namespaceSymbol = getGlobalSymbol(namespace, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined); - let typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, SymbolFlags.Type); + let typeSymbol = getExportedSymbolFromNamespace(namespace, name); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } + function getExportedSymbolFromNamespace(namespace: string, name: string): Symbol { + let namespaceSymbol = getGlobalSymbol(namespace, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined); + return namespaceSymbol && getSymbol(namespaceSymbol.exports, name, SymbolFlags.Type | SymbolFlags.Value); + } + function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } @@ -9345,6 +9386,14 @@ namespace ts { return anyType; } } + + let exprType = checkExpression(node.expression); + if (exprType === cjsRequireType) { + if (node.arguments.length === 1 && node.arguments[0].kind === SyntaxKind.StringLiteral) { + return resolveExternalModuleTypeByLiteral(node.arguments[0]); + } + } + return getReturnTypeOfSignature(signature); } @@ -11965,7 +12014,7 @@ namespace ts { // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent let parent = getDeclarationContainer(node); - if (parent.kind === SyntaxKind.SourceFile && isExternalModule(parent)) { + if (parent.kind === SyntaxKind.SourceFile && isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, declarationNameToString(name), declarationNameToString(name)); @@ -14047,7 +14096,7 @@ namespace ts { forEach(node.statements, checkSourceElement); checkFunctionAndClassExpressionBodies(node); - if (isExternalModule(node)) { + if (isExternalOrCommonJsModule(node)) { checkExternalModuleExports(node); } @@ -14150,7 +14199,7 @@ namespace ts { switch (location.kind) { case SyntaxKind.SourceFile: - if (!isExternalModule(location)) { + if (!isExternalOrCommonJsModule(location)) { break; } case SyntaxKind.ModuleDeclaration: @@ -14881,16 +14930,24 @@ namespace ts { // Initialize global symbol table forEach(host.getSourceFiles(), file => { - if (!isExternalModule(file)) { + if (!isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } }); // Initialize special symbols + if (compilerOptions.allowNonTsExtensions) { + let req = getExportedSymbolFromNamespace("CommonJS", "require"); + if (req) { + globals["require"] = req; + } + } + getSymbolLinks(undefinedSymbol).type = undefinedType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); getSymbolLinks(unknownSymbol).type = unknownType; globals[undefinedSymbol.name] = undefinedSymbol; + // Initialize special types globalArrayType = getGlobalType("Array", /*arity*/ 1); globalObjectType = getGlobalType("Object"); @@ -14913,6 +14970,8 @@ namespace ts { getGlobalPromiseConstructorLikeType = memoize(() => getGlobalType("PromiseConstructorLike")); getGlobalThenableType = memoize(createThenableType); + cjsRequireType = getExportedTypeFromNamespace("CommonJS", "Require"); + // If we're in ES6 mode, load the TemplateStringsArray. // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. if (languageVersion >= ScriptTarget.ES6) { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 307a1ddd50250..6f0aa36306891 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -726,12 +726,7 @@ namespace ts { * List of supported extensions in order of file resolution precedence. */ export const supportedExtensions = [".ts", ".tsx", ".d.ts"]; - /** - * List of extensions that will be used to look for external modules. - * This list is kept separate from supportedExtensions to for cases when we'll allow to include .js files in compilation, - * but still would like to load only TypeScript files as modules - */ - export const moduleFileExtensions = supportedExtensions; + export const supportedJsExtensions = supportedExtensions.concat(".js", ".jsx"); const extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; export function removeFileExtension(path: string): string { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 1551706a33799..b477724475fb4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -527,7 +527,8 @@ namespace ts { let parseErrorBeforeNextFinishedNode = false; export function parseSourceFile(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, setParentNodes?: boolean): SourceFile { - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); + const isJavaScriptFile = hasJavaScriptFileExtension(fileName) || _sourceText.lastIndexOf("// @language=javascript", 0) === 0; + initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor); let result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); @@ -536,7 +537,7 @@ namespace ts { return result; } - function initializeState(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor) { + function initializeState(fileName: string, _sourceText: string, languageVersion: ScriptTarget, isJavaScriptFile: boolean, _syntaxCursor: IncrementalParser.SyntaxCursor) { sourceText = _sourceText; syntaxCursor = _syntaxCursor; @@ -546,7 +547,7 @@ namespace ts { identifierCount = 0; nodeCount = 0; - contextFlags = isJavaScript(fileName) ? ParserContextFlags.JavaScriptFile : ParserContextFlags.None; + contextFlags = isJavaScriptFile ? ParserContextFlags.JavaScriptFile : ParserContextFlags.None; parseErrorBeforeNextFinishedNode = false; // Initialize and prime the scanner before parsing the source elements. @@ -572,6 +573,10 @@ namespace ts { function parseSourceFileWorker(fileName: string, languageVersion: ScriptTarget, setParentNodes: boolean): SourceFile { sourceFile = createSourceFile(fileName, languageVersion); + if (contextFlags & ParserContextFlags.JavaScriptFile) { + sourceFile.parserContextFlags = ParserContextFlags.JavaScriptFile; + } + // Prime the scanner. token = nextToken(); processReferenceComments(sourceFile); @@ -594,7 +599,7 @@ namespace ts { // If this is a javascript file, proactively see if we can get JSDoc comments for // relevant nodes in the file. We'll use these to provide typing informaion if they're // available. - if (isJavaScript(fileName)) { + if (isSourceFileJavaScript(sourceFile)) { addJSDocComments(); } @@ -5486,7 +5491,7 @@ namespace ts { } export function parseJSDocTypeExpressionForTests(content: string, start: number, length: number) { - initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined); + initializeState("file.js", content, ScriptTarget.Latest, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined); let jsDocTypeExpression = parseJSDocTypeExpression(start, length); let diagnostics = parseDiagnostics; clearState(); @@ -5806,7 +5811,7 @@ namespace ts { } export function parseIsolatedJSDocComment(content: string, start: number, length: number) { - initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined); + initializeState("file.js", content, ScriptTarget.Latest, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined); let jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length); let diagnostics = parseDiagnostics; clearState(); diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 86719ff30b4a7..08fd94c60d3b2 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -70,7 +70,7 @@ namespace ts { } function loadNodeModuleFromFile(candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string { - return forEach(moduleFileExtensions, tryLoad); + return forEach(supportedJsExtensions, tryLoad); function tryLoad(ext: string): string { let fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext; @@ -162,9 +162,10 @@ namespace ts { let failedLookupLocations: string[] = []; let referencedSourceFile: string; + let extensions = compilerOptions.allowNonTsExtensions ? supportedJsExtensions : supportedExtensions; while (true) { searchName = normalizePath(combinePaths(searchPath, moduleName)); - referencedSourceFile = forEach(supportedExtensions, extension => { + referencedSourceFile = forEach(extensions, extension => { if (extension === ".tsx" && !compilerOptions.jsx) { // resolve .tsx files only if jsx support is enabled // 'logical not' handles both undefined and None cases @@ -684,6 +685,8 @@ namespace ts { return; } + let isJavaScriptFile = isSourceFileJavaScript(file); + let imports: LiteralExpression[]; for (let node of file.statements) { collect(node, /* allowRelativeModuleNames */ true); @@ -708,6 +711,20 @@ namespace ts { (imports || (imports = [])).push(moduleNameExpr); } break; + case SyntaxKind.CallExpression: + if (isJavaScriptFile && isRequireCall(node)) { + + let jsImports = (node).arguments; + if (jsImports) { + imports = (imports || []); + for (var i = 0; i < jsImports.length; i++) { + if (jsImports[i].kind === SyntaxKind.StringLiteral) { + imports.push(jsImports[i]); + } + } + } + } + break; case SyntaxKind.ModuleDeclaration: if ((node).name.kind === SyntaxKind.StringLiteral && (node.flags & NodeFlags.Ambient || isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 @@ -724,6 +741,10 @@ namespace ts { } break; } + + if (isSourceFileJavaScript(file)) { + forEachChild(node, node => collect(node, allowRelativeModuleNames)); + } } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 6e5528b8217cf..a1665d081ae79 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -764,7 +764,8 @@ namespace ts { expression?: Expression; } - export interface BinaryExpression extends Expression { + // Binary expressions can be declarations if they are 'exports.foo = bar' expressions in JS files + export interface BinaryExpression extends Expression, Declaration { left: Expression; operatorToken: Node; right: Expression; @@ -825,7 +826,7 @@ namespace ts { properties: NodeArray; } - export interface PropertyAccessExpression extends MemberExpression { + export interface PropertyAccessExpression extends MemberExpression, Declaration { expression: LeftHandSideExpression; dotToken: Node; name: Identifier; @@ -1274,6 +1275,8 @@ namespace ts { // The first node that causes this file to be an external module /* @internal */ externalModuleIndicator: Node; + // The first node that causes this file to be a CommonJS module + /* @internal */ commonJsModuleIndicator: Node; /* @internal */ isDefaultLib: boolean; /* @internal */ identifiers: Map; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 2a16c2c71fb93..c5dfcf8947e91 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -362,6 +362,10 @@ namespace ts { return file.externalModuleIndicator !== undefined; } + export function isExternalOrCommonJsModule(file: SourceFile): boolean { + return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; + } + export function isDeclarationFile(file: SourceFile): boolean { return (file.flags & NodeFlags.DeclarationFile) !== 0; } @@ -1031,6 +1035,56 @@ namespace ts { return node.kind === SyntaxKind.ImportEqualsDeclaration && (node).moduleReference.kind !== SyntaxKind.ExternalModuleReference; } + export function isSourceFileJavaScript(file: SourceFile): boolean { + return isInJavaScriptFile(file); + } + + function isInJavaScriptFile(node: Node): boolean { + return node && !!(node.parserContextFlags & ParserContextFlags.JavaScriptFile); + } + + /** + * Returns true if the node is a CallExpression to the identifier 'require' with + * exactly one argument. + * This function does not test if the node is in a JavaScript file or not. + */ + export function isRequireCall(expression: Node): expression is CallExpression { + // of the form 'require("name")' + return expression.kind === SyntaxKind.CallExpression && + (expression).expression.kind === SyntaxKind.Identifier && + ((expression).expression).text === "require" && + (expression).arguments.length === 1; + } + + /** + * Returns true if the node is an assignment to a property on the identifier 'exports'. + * This function does not test if the node is in a JavaScript file or not. + */ + export function isExportsPropertyAssignment(expression: Node): boolean { + // of the form 'exports.name = expr' where 'name' and 'expr' are arbitrary + return isInJavaScriptFile(expression) && + (expression.kind === SyntaxKind.BinaryExpression) && + ((expression).operatorToken.kind === SyntaxKind.EqualsToken) && + ((expression).left.kind === SyntaxKind.PropertyAccessExpression) && + (((expression).left).expression.kind === SyntaxKind.Identifier) && + (((((expression).left).expression)).text === "exports"); + } + + /** + * Returns true if the node is an assignment to the property access expression 'module.exports'. + * This function does not test if the node is in a JavaScript file or not. + */ + export function isModuleExportsAssignment(expression: Node): boolean { + // of the form 'module.exports = expr' where 'expr' is arbitrary + return isInJavaScriptFile(expression) && + (expression.kind === SyntaxKind.BinaryExpression) && + ((expression).operatorToken.kind === SyntaxKind.EqualsToken) && + ((expression).left.kind === SyntaxKind.PropertyAccessExpression) && + (((expression).left).expression.kind === SyntaxKind.Identifier) && + (((((expression).left).expression)).text === "module") && + (((expression).left).name.text === "exports"); + } + export function getExternalModuleName(node: Node): Expression { if (node.kind === SyntaxKind.ImportDeclaration) { return (node).moduleSpecifier; @@ -2083,12 +2137,12 @@ namespace ts { return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined; } - export function isJavaScript(fileName: string) { - return fileExtensionIs(fileName, ".js"); + export function hasJavaScriptFileExtension(fileName: string) { + return fileExtensionIs(fileName, ".js") || fileExtensionIs(fileName, ".jsx"); } export function isTsx(fileName: string) { - return fileExtensionIs(fileName, ".tsx"); + return fileExtensionIs(fileName, ".tsx") || fileExtensionIs(fileName, ".jsx"); } /** diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 457ece7e13271..dd2dde6989c28 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -223,10 +223,22 @@ namespace FourSlash { // Add input file which has matched file name with the given reference-file path. // This is necessary when resolveReference flag is specified - private addMatchedInputFile(referenceFilePath: string) { - let inputFile = this.inputFiles[referenceFilePath]; - if (inputFile && !Harness.isLibraryFile(referenceFilePath)) { - this.languageServiceAdapterHost.addScript(referenceFilePath, inputFile); + private addMatchedInputFile(referenceFilePath: string, extensions: string[]) { + let inputFiles = this.inputFiles; + let languageServiceAdapterHost = this.languageServiceAdapterHost; + if (!extensions) { + tryAdd(referenceFilePath); + } + else { + tryAdd(referenceFilePath) || ts.forEach(extensions, ext => tryAdd(referenceFilePath + ext)); + } + + function tryAdd(path: string) { + let inputFile = inputFiles[path]; + if (inputFile && !Harness.isLibraryFile(path)) { + languageServiceAdapterHost.addScript(path, inputFile); + return true; + } } } @@ -280,15 +292,15 @@ namespace FourSlash { ts.forEach(referencedFiles, referenceFile => { // Fourslash insert tests/cases/fourslash into inputFile.unitName so we will properly append the same base directory to refFile path let referenceFilePath = this.basePath + "/" + referenceFile.fileName; - this.addMatchedInputFile(referenceFilePath); + this.addMatchedInputFile(referenceFilePath, /* extensions */ undefined); }); // Add import files into language-service host ts.forEach(importedFiles, importedFile => { // Fourslash insert tests/cases/fourslash into inputFile.unitName and import statement doesn't require ".ts" // so convert them before making appropriate comparison - let importedFilePath = this.basePath + "/" + importedFile.fileName + ".ts"; - this.addMatchedInputFile(importedFilePath); + let importedFilePath = this.basePath + "/" + importedFile.fileName; + this.addMatchedInputFile(importedFilePath, compilationOptions.allowNonTsExtensions ? ts.supportedJsExtensions : ts.supportedExtensions); }); // Check if no-default-lib flag is false and if so add default library @@ -2257,15 +2269,15 @@ namespace FourSlash { let details = this.getCompletionEntryDetails(item.name); if (documentation !== undefined) { - assert.equal(ts.displayPartsToString(details.documentation), documentation, assertionMessage("completion item documentation")); + assert.equal(ts.displayPartsToString(details.documentation), documentation, assertionMessage("completion item documentation for " + name)); } if (text !== undefined) { - assert.equal(ts.displayPartsToString(details.displayParts), text, assertionMessage("completion item detail text")); + assert.equal(ts.displayPartsToString(details.displayParts), text, assertionMessage("completion item detail text for " + name)); } } if (kind !== undefined) { - assert.equal(item.kind, kind, assertionMessage("completion item kind")); + assert.equal(item.kind, kind, assertionMessage("completion item kind for " + name)); } return; diff --git a/src/harness/harness.ts b/src/harness/harness.ts index a37b647a12490..91897493fd92f 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -211,7 +211,7 @@ namespace Utils { return isNodeOrArray(v) ? serializeNode(v) : v; }, " "); - function getKindName(k: number | string): string { + function getKindName(k: number|string): string { if (typeof k === "string") { return k; } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index dfde2bd1c08bf..688b7f0b9064e 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -197,7 +197,7 @@ namespace Harness.LanguageService { getHost() { return this.host; } getLanguageService(): ts.LanguageService { return ts.createLanguageService(this.host); } getClassifier(): ts.Classifier { return ts.createClassifier(); } - getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo { return ts.preProcessFile(fileContents); } + getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo { return ts.preProcessFile(fileContents, /* readImportFiles */ true, ts.hasJavaScriptFileExtension(fileName)); } } /// Shim adapter diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts index 7259ff5081c31..86dee00638d19 100644 --- a/src/lib/core.d.ts +++ b/src/lib/core.d.ts @@ -1183,6 +1183,22 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } + +declare namespace CommonJS { + export var require: Require; + + export var exports: any; + + interface Exports { } + interface Module { + exports: Exports; + } + + interface Require { + (moduleName: string): any; + } +} + interface ArrayLike { length: number; [n: number]: T; diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 436b97821ccd5..8ea216eefe6ea 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -361,6 +361,10 @@ namespace ts.server { openRefCount = 0; constructor(public projectService: ProjectService, public projectOptions?: ProjectOptions) { + if(projectOptions && projectOptions.files){ + // If files are listed explicitly, allow all extensions + projectOptions.compilerOptions.allowNonTsExtensions = true; + } this.compilerService = new CompilerService(this, projectOptions && projectOptions.compilerOptions); } @@ -449,6 +453,7 @@ namespace ts.server { setProjectOptions(projectOptions: ProjectOptions) { this.projectOptions = projectOptions; if (projectOptions.compilerOptions) { + projectOptions.compilerOptions.allowNonTsExtensions = true; this.compilerService.setCompilerOptions(projectOptions.compilerOptions); } } @@ -1156,7 +1161,9 @@ namespace ts.server { this.setCompilerOptions(opt); } else { - this.setCompilerOptions(ts.getDefaultCompilerOptions()); + var defaultOpts = ts.getDefaultCompilerOptions(); + defaultOpts.allowNonTsExtensions = true; + this.setCompilerOptions(defaultOpts); } this.languageService = ts.createLanguageService(this.host, this.documentRegistry); this.classifier = ts.createClassifier(); diff --git a/src/services/services.ts b/src/services/services.ts index 15c6e3df56f8f..a6611a3d39a57 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -794,6 +794,7 @@ namespace ts { public isDefaultLib: boolean; public hasNoDefaultLib: boolean; public externalModuleIndicator: Node; // The first node that causes this file to be an external module + public commonJsModuleIndicator: Node; // The first node that causes this file to be a CommonJS module public nodeCount: number; public identifierCount: number; public symbolCount: number; @@ -2108,7 +2109,7 @@ namespace ts { }; } - export function preProcessFile(sourceText: string, readImportFiles = true): PreProcessedFileInfo { + export function preProcessFile(sourceText: string, readImportFiles = true, detectJavaScriptImports = false): PreProcessedFileInfo { let referencedFiles: FileReference[] = []; let importedFiles: FileReference[] = []; let ambientExternalModules: string[]; @@ -2146,119 +2147,69 @@ namespace ts { }); } - function processImport(): void { - scanner.setText(sourceText); - let token = scanner.scan(); - // Look for: - // import "mod"; - // import d from "mod" - // import {a as A } from "mod"; - // import * as NS from "mod" - // import d, {a, b as B} from "mod" - // import i = require("mod"); - // - // export * from "mod" - // export {a as b} from "mod" - // export import i = require("mod") - - while (token !== SyntaxKind.EndOfFileToken) { - if (token === SyntaxKind.DeclareKeyword) { - // declare module "mod" - token = scanner.scan(); - if (token === SyntaxKind.ModuleKeyword) { - token = scanner.scan(); - if (token === SyntaxKind.StringLiteral) { - recordAmbientExternalModule(); - continue; - } - } - } - else if (token === SyntaxKind.ImportKeyword) { + /** + * Returns true if at least one token was consumed from the stream + */ + function tryConsumeDeclare(): boolean { + let token = scanner.getToken(); + if (token === SyntaxKind.DeclareKeyword) { + // declare module "mod" + token = scanner.scan(); + if (token === SyntaxKind.ModuleKeyword) { token = scanner.scan(); if (token === SyntaxKind.StringLiteral) { - // import "mod"; - recordModuleName(); - continue; + recordAmbientExternalModule(); } - else { - if (token === SyntaxKind.Identifier || isKeyword(token)) { - token = scanner.scan(); - if (token === SyntaxKind.FromKeyword) { - token = scanner.scan(); - if (token === SyntaxKind.StringLiteral) { - // import d from "mod"; - recordModuleName(); - continue - } - } - else if (token === SyntaxKind.EqualsToken) { - token = scanner.scan(); - if (token === SyntaxKind.RequireKeyword) { - token = scanner.scan(); - if (token === SyntaxKind.OpenParenToken) { - token = scanner.scan(); - if (token === SyntaxKind.StringLiteral) { - // import i = require("mod"); - recordModuleName(); - continue; - } - } - } - } - else if (token === SyntaxKind.CommaToken) { - // consume comma and keep going - token = scanner.scan(); - } - else { - // unknown syntax - continue; - } - } + } + return true; + } + + return false; + } - if (token === SyntaxKind.OpenBraceToken) { + /** + * Returns true if at least one token was consumed from the stream + */ + function tryConsumeImport(): boolean { + let token = scanner.getToken(); + if (token === SyntaxKind.ImportKeyword) { + token = scanner.scan(); + if (token === SyntaxKind.StringLiteral) { + // import "mod"; + recordModuleName(); + return true; + } + else { + if (token === SyntaxKind.Identifier || isKeyword(token)) { + token = scanner.scan(); + if (token === SyntaxKind.FromKeyword) { token = scanner.scan(); - // consume "{ a as B, c, d as D}" clauses - while (token !== SyntaxKind.CloseBraceToken) { - token = scanner.scan(); + if (token === SyntaxKind.StringLiteral) { + // import d from "mod"; + recordModuleName(); + return true; } - - if (token === SyntaxKind.CloseBraceToken) { - token = scanner.scan(); - if (token === SyntaxKind.FromKeyword) { - token = scanner.scan(); - if (token === SyntaxKind.StringLiteral) { - // import {a as A} from "mod"; - // import d, {a, b as B} from "mod" - recordModuleName(); - } - } + } + else if (token === SyntaxKind.EqualsToken) { + if (tryConsumeRequireCall(/* skipCurrentToken */ true)) { + return true; } } - else if (token === SyntaxKind.AsteriskToken) { + else if (token === SyntaxKind.CommaToken) { + // consume comma and keep going token = scanner.scan(); - if (token === SyntaxKind.AsKeyword) { - token = scanner.scan(); - if (token === SyntaxKind.Identifier || isKeyword(token)) { - token = scanner.scan(); - if (token === SyntaxKind.FromKeyword) { - token = scanner.scan(); - if (token === SyntaxKind.StringLiteral) { - // import * as NS from "mod" - // import d, * as NS from "mod" - recordModuleName(); - } - } - } - } + } + else { + // unknown syntax + return true; } } - } - else if (token === SyntaxKind.ExportKeyword) { - token = scanner.scan(); + if (token === SyntaxKind.OpenBraceToken) { token = scanner.scan(); // consume "{ a as B, c, d as D}" clauses - while (token !== SyntaxKind.CloseBraceToken) { + // make sure that it stops on EOF + while (token !== SyntaxKind.CloseBraceToken && token !== SyntaxKind.EndOfFileToken) { token = scanner.scan(); } @@ -2267,50 +2218,203 @@ namespace ts { if (token === SyntaxKind.FromKeyword) { token = scanner.scan(); if (token === SyntaxKind.StringLiteral) { - // export {a as A} from "mod"; - // export {a, b as B} from "mod" + // import {a as A} from "mod"; + // import d, {a, b as B} from "mod" recordModuleName(); } } } } else if (token === SyntaxKind.AsteriskToken) { + token = scanner.scan(); + if (token === SyntaxKind.AsKeyword) { + token = scanner.scan(); + if (token === SyntaxKind.Identifier || isKeyword(token)) { + token = scanner.scan(); + if (token === SyntaxKind.FromKeyword) { + token = scanner.scan(); + if (token === SyntaxKind.StringLiteral) { + // import * as NS from "mod" + // import d, * as NS from "mod" + recordModuleName(); + } + } + } + } + } + } + + return true; + } + + return false; + } + + function tryConsumeExport(): boolean { + let token = scanner.getToken(); + if (token === SyntaxKind.ExportKeyword) { + token = scanner.scan(); + if (token === SyntaxKind.OpenBraceToken) { + token = scanner.scan(); + // consume "{ a as B, c, d as D}" clauses + // make sure it stops on EOF + while (token !== SyntaxKind.CloseBraceToken && token !== SyntaxKind.EndOfFileToken) { + token = scanner.scan(); + } + + if (token === SyntaxKind.CloseBraceToken) { token = scanner.scan(); if (token === SyntaxKind.FromKeyword) { token = scanner.scan(); if (token === SyntaxKind.StringLiteral) { - // export * from "mod" + // export {a as A} from "mod"; + // export {a, b as B} from "mod" recordModuleName(); } } } - else if (token === SyntaxKind.ImportKeyword) { + } + else if (token === SyntaxKind.AsteriskToken) { + token = scanner.scan(); + if (token === SyntaxKind.FromKeyword) { token = scanner.scan(); - if (token === SyntaxKind.Identifier || isKeyword(token)) { - token = scanner.scan(); - if (token === SyntaxKind.EqualsToken) { - token = scanner.scan(); - if (token === SyntaxKind.RequireKeyword) { - token = scanner.scan(); - if (token === SyntaxKind.OpenParenToken) { - token = scanner.scan(); - if (token === SyntaxKind.StringLiteral) { - // export import i = require("mod"); - recordModuleName(); - } - } - } + if (token === SyntaxKind.StringLiteral) { + // export * from "mod" + recordModuleName(); + } + } + } + else if (token === SyntaxKind.ImportKeyword) { + token = scanner.scan(); + if (token === SyntaxKind.Identifier || isKeyword(token)) { + token = scanner.scan(); + if (token === SyntaxKind.EqualsToken) { + if (tryConsumeRequireCall(/* skipCurrentToken */ true)) { + return true; } } } } + + return true; + } + + return false; + } + + function tryConsumeRequireCall(skipCurrentToken: boolean): boolean { + let token = skipCurrentToken ? scanner.scan() : scanner.getToken(); + if (token === SyntaxKind.RequireKeyword) { + token = scanner.scan(); + if (token === SyntaxKind.OpenParenToken) { + token = scanner.scan(); + if (token === SyntaxKind.StringLiteral) { + // require("mod"); + recordModuleName(); + } + } + return true; + } + return false; + } + + function tryConsumeDefine(): boolean { + let token = scanner.getToken(); + if (token === SyntaxKind.Identifier && scanner.getTokenValue() === "define") { + token = scanner.scan(); + if (token !== SyntaxKind.OpenParenToken) { + return true; + } + + token = scanner.scan(); + if (token === SyntaxKind.StringLiteral) { + // looks like define ("modname", ... - skip string literal and comma + token = scanner.scan(); + if (token === SyntaxKind.CommaToken) { + token = scanner.scan(); + } + else { + // unexpected token + return true; + } + } + + // should be start of dependency list + if (token !== SyntaxKind.OpenBracketToken) { + return true; + } + + // skip open bracket token = scanner.scan(); + let i = 0; + // scan until ']' or EOF + while (token !== SyntaxKind.CloseBracketToken && token !== SyntaxKind.EndOfFileToken) { + // record string literals as module names + if (token === SyntaxKind.StringLiteral) { + const moduleName = scanner.getTokenValue(); + // record first item in the list only if its name is not "require" + // record second item in the list only if its name is not "exports" + // record third item in the list only if its name is not "module" + // record all other items in the list unconditionally + const shouldRecordName = + i === 0 + ? moduleName !== "require" + : i === 1 + ? moduleName !== "exports" + : i !== 2 || moduleName !== "module"; + + if (shouldRecordName) { + recordModuleName(); + } + i++; + } + + token = scanner.scan(); + } + return true; + } + return false; + } + + function processImports(): void { + scanner.setText(sourceText); + scanner.scan(); + // Look for: + // import "mod"; + // import d from "mod" + // import {a as A } from "mod"; + // import * as NS from "mod" + // import d, {a, b as B} from "mod" + // import i = require("mod"); + // + // export * from "mod" + // export {a as b} from "mod" + // export import i = require("mod") + // (for JavaScript files) require("mod") + + while (true) { + if (scanner.getToken() === SyntaxKind.EndOfFileToken) { + break; + } + + // check if at least one of alternative have moved scanner forward + if (tryConsumeDeclare() || + tryConsumeImport() || + tryConsumeExport() || + (detectJavaScriptImports && (tryConsumeRequireCall(/* skipCurrentToken */ false) || tryConsumeDefine()))) { + continue; + } + else { + scanner.scan(); + } + } + scanner.setText(undefined); } if (readImportFiles) { - processImport(); + processImports(); } processTripleSlashDirectives(); return { referencedFiles, importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules }; @@ -2797,7 +2901,7 @@ namespace ts { // For JavaScript files, we don't want to report the normal typescript semantic errors. // Instead, we just report errors for using TypeScript-only constructs from within a // JavaScript file. - if (isJavaScript(fileName)) { + if (isSourceFileJavaScript(targetSourceFile)) { return getJavaScriptSemanticDiagnostics(targetSourceFile); } @@ -3036,7 +3140,7 @@ namespace ts { let typeChecker = program.getTypeChecker(); let syntacticStart = new Date().getTime(); let sourceFile = getValidSourceFile(fileName); - let isJavaScriptFile = isJavaScript(fileName); + let isJavaScriptFile = isSourceFileJavaScript(sourceFile); let isJsDocTagName = false; @@ -3857,22 +3961,25 @@ namespace ts { let { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot, isJsDocTagName } = completionData; - let entries: CompletionEntry[]; if (isJsDocTagName) { // If the current position is a jsDoc tag name, only tag names should be provided for completion return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; } - if (isRightOfDot && isJavaScript(fileName)) { - entries = getCompletionEntriesFromSymbols(symbols); - addRange(entries, getJavaScriptCompletionEntries()); + let sourceFile = getValidSourceFile(fileName); + + let entries: CompletionEntry[] = []; + + if (isRightOfDot && isSourceFileJavaScript(sourceFile)) { + const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries); + addRange(entries, getJavaScriptCompletionEntries(sourceFile, uniqueNames)); } else { if (!symbols || symbols.length === 0) { return undefined; } - entries = getCompletionEntriesFromSymbols(symbols); + getCompletionEntriesFromSymbols(symbols, entries); } // Add keywords if this is not a member completion list @@ -3882,26 +3989,23 @@ namespace ts { return { isMemberCompletion, isNewIdentifierLocation, entries }; - function getJavaScriptCompletionEntries(): CompletionEntry[] { + function getJavaScriptCompletionEntries(sourceFile: SourceFile, uniqueNames: Map): CompletionEntry[] { let entries: CompletionEntry[] = []; - let allNames: Map = {}; let target = program.getCompilerOptions().target; - for (let sourceFile of program.getSourceFiles()) { - let nameTable = getNameTable(sourceFile); - for (let name in nameTable) { - if (!allNames[name]) { - allNames[name] = name; - let displayName = getCompletionEntryDisplayName(name, target, /*performCharacterChecks:*/ true); - if (displayName) { - let entry = { - name: displayName, - kind: ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; - entries.push(entry); - } + let nameTable = getNameTable(sourceFile); + for (let name in nameTable) { + if (!uniqueNames[name]) { + uniqueNames[name] = name; + let displayName = getCompletionEntryDisplayName(name, target, /*performCharacterChecks:*/ true); + if (displayName) { + let entry = { + name: displayName, + kind: ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); } } } @@ -3945,26 +4049,24 @@ namespace ts { }; } - function getCompletionEntriesFromSymbols(symbols: Symbol[]): CompletionEntry[] { + function getCompletionEntriesFromSymbols(symbols: Symbol[], entries: CompletionEntry[]): Map { let start = new Date().getTime(); - let entries: CompletionEntry[] = []; - + let uniqueNames: Map = {}; if (symbols) { - let nameToSymbol: Map = {}; for (let symbol of symbols) { let entry = createCompletionEntry(symbol, location); if (entry) { let id = escapeIdentifier(entry.name); - if (!lookUp(nameToSymbol, id)) { + if (!lookUp(uniqueNames, id)) { entries.push(entry); - nameToSymbol[id] = symbol; + uniqueNames[id] = id; } } } } log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start)); - return entries; + return uniqueNames; } } diff --git a/src/services/shims.ts b/src/services/shims.ts index 351514a1499bb..686faf0e1bdae 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -957,7 +957,8 @@ namespace ts { return this.forwardJSONCall( "getPreProcessedFileInfo('" + fileName + "')", () => { - var result = preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); + // for now treat files as JavaScript + var result = preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), /* readImportFiles */ true, /* detectJavaScriptImports */ true); var convertResult = { referencedFiles: [], importedFiles: [], diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index df321647e5c52..02e36e185a56a 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -204,7 +204,7 @@ namespace ts.SignatureHelp { if (!candidates.length) { // We didn't have any sig help items produced by the TS compiler. If this is a JS // file, then see if we can figure out anything better. - if (isJavaScript(sourceFile.fileName)) { + if (isSourceFileJavaScript(sourceFile)) { return createJavaScriptSignatureHelpItems(argumentInfo); } diff --git a/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics1.ts b/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics1.ts deleted file mode 100644 index e409029276b62..0000000000000 --- a/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics1.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -// @allowNonTsExtensions: true -// @Filename: a.js -//// /** -//// * @type {number} -//// * @type {string} -//// */ -//// var v; - -verify.getSyntacticDiagnostics(`[ - { - "message": "\'type\' tag already specified.", - "start": 26, - "length": 4, - "category": "error", - "code": 1223 - } -]`); \ No newline at end of file diff --git a/tests/cases/fourslash/javaScriptModules12.ts b/tests/cases/fourslash/javaScriptModules12.ts new file mode 100644 index 0000000000000..c391f150963f1 --- /dev/null +++ b/tests/cases/fourslash/javaScriptModules12.ts @@ -0,0 +1,57 @@ +/// + +// Invocations of 'require' stop top-level variables from becoming global + +// @allowNonTsExtensions: true + +// @Filename: mod1.js +//// var x = require('fs'); +//// /*1*/ + +// @Filename: mod2.js +//// var y; +//// if(true) { +//// y = require('fs'); +//// } +//// /*2*/ + +// @Filename: glob1.js +//// var a = require; +//// /*3*/ + +// @Filename: glob2.js +//// var b = ''; +//// /*4*/ + +// @Filename: consumer.js +//// /*5*/ + +goTo.marker('1'); +verify.completionListContains('x'); +verify.not.completionListContains('y'); +verify.completionListContains('a'); +verify.completionListContains('b'); + +goTo.marker('2'); +verify.not.completionListContains('x'); +verify.completionListContains('y'); +verify.completionListContains('a'); +verify.completionListContains('b'); + +goTo.marker('3'); +verify.not.completionListContains('x'); +verify.not.completionListContains('y'); +verify.completionListContains('a'); +verify.completionListContains('b'); + +goTo.marker('4'); +verify.not.completionListContains('x'); +verify.not.completionListContains('y'); +verify.completionListContains('a'); +verify.completionListContains('b'); + +goTo.marker('5'); +verify.not.completionListContains('x'); +verify.not.completionListContains('y'); +verify.completionListContains('a'); +verify.completionListContains('b'); diff --git a/tests/cases/fourslash/javaScriptModules13.ts b/tests/cases/fourslash/javaScriptModules13.ts new file mode 100644 index 0000000000000..215f47e9ad61a --- /dev/null +++ b/tests/cases/fourslash/javaScriptModules13.ts @@ -0,0 +1,29 @@ +/// + +// Assignments to 'module.exports' create an external module + +// @allowNonTsExtensions: true +// @Filename: myMod.js +//// if (true) { +//// module.exports = { a: 10 }; +//// } else { +//// module.exports = { b: 10 }; +//// } +//// var invisible = true; + +// @Filename: isGlobal.js +//// var y = 10; + +// @Filename: consumer.js +//// var x = require('myMod'); +//// /**/; + +goTo.file('consumer.js'); +goTo.marker(); + +verify.completionListContains('y'); +verify.not.completionListContains('invisible'); + +edit.insert('x.'); +verify.completionListContains('a'); +verify.completionListContains('b'); diff --git a/tests/cases/fourslash/javaScriptModules14.ts b/tests/cases/fourslash/javaScriptModules14.ts new file mode 100644 index 0000000000000..5434f94cf8de6 --- /dev/null +++ b/tests/cases/fourslash/javaScriptModules14.ts @@ -0,0 +1,28 @@ +/// + +// Assignments to 'exports.p' stop global variables from being visible in other files + +// @allowNonTsExtensions: true +// @Filename: myMod.js +//// if (true) { +//// exports.b = true; +//// } else { +//// exports.n = 3; +//// } +//// function fn() { +//// exports.s = 'foo'; +//// } +//// var invisible = true; + +// @Filename: isGlobal.js +//// var y = 10; + +// @Filename: consumer.js +//// var x = require('myMod'); +//// /**/; + +goTo.file('consumer.js'); +goTo.marker(); + +verify.completionListContains('y'); +verify.not.completionListContains('invisible'); diff --git a/tests/cases/fourslash/javaScriptModules15.ts b/tests/cases/fourslash/javaScriptModules15.ts new file mode 100644 index 0000000000000..ff888d993367f --- /dev/null +++ b/tests/cases/fourslash/javaScriptModules15.ts @@ -0,0 +1,27 @@ +/// + +// Assignments to 'exports.p' define a property 'p' even if they're not at top-level + +// @allowNonTsExtensions: true +// @Filename: myMod.js +//// if (true) { +//// exports.b = true; +//// } else { +//// exports.n = 3; +//// } +//// function fn() { +//// exports.s = 'foo'; +//// } + +// @Filename: consumer.js +//// var x = require('myMod'); +//// x/**/; + +goTo.file('consumer.js'); +goTo.marker(); +edit.insert('.'); +verify.completionListContains("n", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("s", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("b", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +edit.insert('n.'); +verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); diff --git a/tests/cases/fourslash/javaScriptModules16.ts b/tests/cases/fourslash/javaScriptModules16.ts new file mode 100644 index 0000000000000..c556f288145cb --- /dev/null +++ b/tests/cases/fourslash/javaScriptModules16.ts @@ -0,0 +1,22 @@ +/// + +// Assignments to 'exports.p' define a property 'p' + +// @allowNonTsExtensions: true +// @Filename: myMod.js +//// exports.n = 3; +//// exports.s = 'foo'; +//// exports.b = true; + +// @Filename: consumer.js +//// var x = require('myMod'); +//// x/**/; + +goTo.file('consumer.js'); +goTo.marker(); +edit.insert('.'); +verify.completionListContains("n", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("s", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("b", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +edit.insert('n.'); +verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); diff --git a/tests/cases/fourslash/javaScriptModules17.ts b/tests/cases/fourslash/javaScriptModules17.ts new file mode 100644 index 0000000000000..8514ed0ee1844 --- /dev/null +++ b/tests/cases/fourslash/javaScriptModules17.ts @@ -0,0 +1,18 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: myMod.js +//// module.exports = { n: 3, s: 'foo', b: true }; + +// @Filename: consumer.js +//// var x = require('./myMod'); +//// x/**/; + +goTo.file('consumer.js'); +goTo.marker(); +edit.insert('.'); +verify.completionListContains("n", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("s", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("b", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +edit.insert('n.'); +verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); diff --git a/tests/cases/fourslash/javaScriptModules18.ts b/tests/cases/fourslash/javaScriptModules18.ts new file mode 100644 index 0000000000000..d3117f86b3f35 --- /dev/null +++ b/tests/cases/fourslash/javaScriptModules18.ts @@ -0,0 +1,14 @@ +/// + +// CommonJS modules should not pollute the global namespace + +// @allowNonTsExtensions: true +// @Filename: myMod.js +//// var x = require('fs'); + +// @Filename: other.js +//// /**/; + +goTo.file('other.js'); + +verify.not.completionListContains('x'); diff --git a/tests/cases/unittests/moduleResolution.ts b/tests/cases/unittests/moduleResolution.ts index b5c2c70e491ac..7e363d80d6d4d 100644 --- a/tests/cases/unittests/moduleResolution.ts +++ b/tests/cases/unittests/moduleResolution.ts @@ -82,7 +82,7 @@ module ts { assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name); assert.equal(!!resolution.resolvedModule.isExternalLibraryImport, false); // expect three failed lookup location - attempt to load module as file with all supported extensions - assert.equal(resolution.failedLookupLocations.length, 3); + assert.equal(resolution.failedLookupLocations.length, 5); } it("module name as directory - load from typings", () => { @@ -103,6 +103,8 @@ module ts { "/a/b/foo.ts", "/a/b/foo.tsx", "/a/b/foo.d.ts", + "/a/b/foo.js", + "/a/b/foo.jsx", "/a/b/foo/index.ts", "/a/b/foo/index.tsx", ]); @@ -119,17 +121,25 @@ module ts { "/a/b/c/d/node_modules/foo.ts", "/a/b/c/d/node_modules/foo.tsx", "/a/b/c/d/node_modules/foo.d.ts", + "/a/b/c/d/node_modules/foo.js", + "/a/b/c/d/node_modules/foo.jsx", "/a/b/c/d/node_modules/foo/package.json", "/a/b/c/d/node_modules/foo/index.ts", "/a/b/c/d/node_modules/foo/index.tsx", "/a/b/c/d/node_modules/foo/index.d.ts", + "/a/b/c/d/node_modules/foo/index.js", + "/a/b/c/d/node_modules/foo/index.jsx", "/a/b/c/node_modules/foo.ts", "/a/b/c/node_modules/foo.tsx", "/a/b/c/node_modules/foo.d.ts", + "/a/b/c/node_modules/foo.js", + "/a/b/c/node_modules/foo.jsx", "/a/b/c/node_modules/foo/package.json", "/a/b/c/node_modules/foo/index.ts", "/a/b/c/node_modules/foo/index.tsx", - "/a/b/c/node_modules/foo/index.d.ts" + "/a/b/c/node_modules/foo/index.d.ts", + "/a/b/c/node_modules/foo/index.js", + "/a/b/c/node_modules/foo/index.jsx" ]) }); @@ -151,27 +161,41 @@ module ts { "/a/node_modules/b/c/node_modules/d/node_modules/foo.ts", "/a/node_modules/b/c/node_modules/d/node_modules/foo.tsx", "/a/node_modules/b/c/node_modules/d/node_modules/foo.d.ts", + "/a/node_modules/b/c/node_modules/d/node_modules/foo.js", + "/a/node_modules/b/c/node_modules/d/node_modules/foo.jsx", "/a/node_modules/b/c/node_modules/d/node_modules/foo/package.json", "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.ts", "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.tsx", "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.d.ts", + "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.js", + "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.jsx", "/a/node_modules/b/c/node_modules/foo.ts", "/a/node_modules/b/c/node_modules/foo.tsx", "/a/node_modules/b/c/node_modules/foo.d.ts", + "/a/node_modules/b/c/node_modules/foo.js", + "/a/node_modules/b/c/node_modules/foo.jsx", "/a/node_modules/b/c/node_modules/foo/package.json", "/a/node_modules/b/c/node_modules/foo/index.ts", "/a/node_modules/b/c/node_modules/foo/index.tsx", "/a/node_modules/b/c/node_modules/foo/index.d.ts", + "/a/node_modules/b/c/node_modules/foo/index.js", + "/a/node_modules/b/c/node_modules/foo/index.jsx", "/a/node_modules/b/node_modules/foo.ts", "/a/node_modules/b/node_modules/foo.tsx", "/a/node_modules/b/node_modules/foo.d.ts", + "/a/node_modules/b/node_modules/foo.js", + "/a/node_modules/b/node_modules/foo.jsx", "/a/node_modules/b/node_modules/foo/package.json", "/a/node_modules/b/node_modules/foo/index.ts", "/a/node_modules/b/node_modules/foo/index.tsx", "/a/node_modules/b/node_modules/foo/index.d.ts", + "/a/node_modules/b/node_modules/foo/index.js", + "/a/node_modules/b/node_modules/foo/index.jsx", "/a/node_modules/foo.ts", "/a/node_modules/foo.tsx", "/a/node_modules/foo.d.ts", + "/a/node_modules/foo.js", + "/a/node_modules/foo.jsx", "/a/node_modules/foo/package.json", "/a/node_modules/foo/index.ts", "/a/node_modules/foo/index.tsx" diff --git a/tests/cases/unittests/services/preProcessFile.ts b/tests/cases/unittests/services/preProcessFile.ts index a3f8db5528fba..aba5ce15c0392 100644 --- a/tests/cases/unittests/services/preProcessFile.ts +++ b/tests/cases/unittests/services/preProcessFile.ts @@ -2,8 +2,8 @@ /// describe('PreProcessFile:', function () { - function test(sourceText: string, readImportFile: boolean, expectedPreProcess: ts.PreProcessedFileInfo): void { - var resultPreProcess = ts.preProcessFile(sourceText, readImportFile); + function test(sourceText: string, readImportFile: boolean, detectJavaScriptImports: boolean, expectedPreProcess: ts.PreProcessedFileInfo): void { + var resultPreProcess = ts.preProcessFile(sourceText, readImportFile, detectJavaScriptImports); var resultIsLibFile = resultPreProcess.isLibFile; var resultImportedFiles = resultPreProcess.importedFiles; @@ -45,7 +45,9 @@ describe('PreProcessFile:', function () { } describe("Test preProcessFiles,", function () { it("Correctly return referenced files from triple slash", function () { - test("///" + "\n" + "///" + "\n" + "///" + "\n" + "///", true, + test("///" + "\n" + "///" + "\n" + "///" + "\n" + "///", + /* readImports */true, + /* detectJavaScriptImports */ false, { referencedFiles: [{ fileName: "refFile1.ts", pos: 0, end: 37 }, { fileName: "refFile2.ts", pos: 38, end: 73 }, { fileName: "refFile3.ts", pos: 74, end: 109 }, { fileName: "..\\refFile4d.ts", pos: 110, end: 150 }], @@ -56,7 +58,9 @@ describe('PreProcessFile:', function () { }), it("Do not return reference path because of invalid triple-slash syntax", function () { - test("///" + "\n" + "///" + "\n" + "///" + "\n" + "///", true, + test("///" + "\n" + "///" + "\n" + "///" + "\n" + "///", + /* readImports */true, + /* detectJavaScriptImports */ false, { referencedFiles: [], importedFiles: [], @@ -66,7 +70,9 @@ describe('PreProcessFile:', function () { }), it("Correctly return imported files", function () { - test("import i1 = require(\"r1.ts\"); import i2 =require(\"r2.ts\"); import i3= require(\"r3.ts\"); import i4=require(\"r4.ts\"); import i5 = require (\"r5.ts\");", true, + test("import i1 = require(\"r1.ts\"); import i2 =require(\"r2.ts\"); import i3= require(\"r3.ts\"); import i4=require(\"r4.ts\"); import i5 = require (\"r5.ts\");", + /* readImports */true, + /* detectJavaScriptImports */ false, { referencedFiles: [], importedFiles: [{ fileName: "r1.ts", pos: 20, end: 25 }, { fileName: "r2.ts", pos: 49, end: 54 }, { fileName: "r3.ts", pos: 78, end: 83 }, @@ -77,7 +83,9 @@ describe('PreProcessFile:', function () { }), it("Do not return imported files if readImportFiles argument is false", function () { - test("import i1 = require(\"r1.ts\"); import i2 =require(\"r2.ts\"); import i3= require(\"r3.ts\"); import i4=require(\"r4.ts\"); import i5 = require (\"r5.ts\");", false, + test("import i1 = require(\"r1.ts\"); import i2 =require(\"r2.ts\"); import i3= require(\"r3.ts\"); import i4=require(\"r4.ts\"); import i5 = require (\"r5.ts\");", + /* readImports */ false, + /* detectJavaScriptImports */ false, { referencedFiles: [], importedFiles: [], @@ -87,7 +95,9 @@ describe('PreProcessFile:', function () { }), it("Do not return import path because of invalid import syntax", function () { - test("import i1 require(\"r1.ts\"); import = require(\"r2.ts\") import i3= require(\"r3.ts\"); import i5", true, + test("import i1 require(\"r1.ts\"); import = require(\"r2.ts\") import i3= require(\"r3.ts\"); import i5", + /* readImports */true, + /* detectJavaScriptImports */ false, { referencedFiles: [], importedFiles: [{ fileName: "r3.ts", pos: 73, end: 78 }], @@ -97,7 +107,9 @@ describe('PreProcessFile:', function () { }), it("Correctly return referenced files and import files", function () { - test("///" + "\n" + "///" + "\n" + "import i1 = require(\"r1.ts\"); import i2 =require(\"r2.ts\");", true, + test("///" + "\n" + "///" + "\n" + "import i1 = require(\"r1.ts\"); import i2 =require(\"r2.ts\");", + /* readImports */true, + /* detectJavaScriptImports */ false, { referencedFiles: [{ fileName: "refFile1.ts", pos: 0, end: 35 }, { fileName: "refFile2.ts", pos: 36, end: 71 }], importedFiles: [{ fileName: "r1.ts", pos: 92, end: 97 }, { fileName: "r2.ts", pos: 121, end: 126 }], @@ -107,7 +119,9 @@ describe('PreProcessFile:', function () { }), it("Correctly return referenced files and import files even with some invalid syntax", function () { - test("///" + "\n" + "///" + "\n" + "import i1 = require(\"r1.ts\"); import = require(\"r2.ts\"); import i2 = require(\"r3.ts\");", true, + test("///" + "\n" + "///" + "\n" + "import i1 = require(\"r1.ts\"); import = require(\"r2.ts\"); import i2 = require(\"r3.ts\");", + /* readImports */true, + /* detectJavaScriptImports */ false, { referencedFiles: [{ fileName: "refFile1.ts", pos: 0, end: 35 }], importedFiles: [{ fileName: "r1.ts", pos: 91, end: 96 }, { fileName: "r3.ts", pos: 148, end: 153 }], @@ -124,7 +138,8 @@ describe('PreProcessFile:', function () { "import {a as A} from \"m5\";" + "\n" + "import {a as A, b, c as C} from \"m6\";" + "\n" + "import def , {a, b, c as C} from \"m7\";" + "\n", - true, + /* readImports */true, + /* detectJavaScriptImports */ false, { referencedFiles: [], importedFiles: [ @@ -146,7 +161,8 @@ describe('PreProcessFile:', function () { "export {a} from \"m2\";" + "\n" + "export {a as A} from \"m3\";" + "\n" + "export {a as A, b, c as C} from \"m4\";" + "\n", - true, + /* readImports */true, + /* detectJavaScriptImports */ false, { referencedFiles: [], importedFiles: [ @@ -166,7 +182,11 @@ describe('PreProcessFile:', function () { declare module "B" {} function foo() { } - `, false, { + `, + /* readImports */ false, + /* detectJavaScriptImports */ false, + + { referencedFiles: [], importedFiles: [], ambientExternalModules: ["B"], @@ -176,7 +196,8 @@ describe('PreProcessFile:', function () { it("Correctly handles export import declarations", function () { test("export import a = require(\"m1\");", - true, + /* readImports */true, + /* detectJavaScriptImports */ false, { referencedFiles: [], importedFiles: [ @@ -186,7 +207,109 @@ describe('PreProcessFile:', function () { isLibFile: false }) }); + it("Correctly handles export require calls in JavaScript files", function () { + test(` + export import a = require("m1"); + var x = require('m2'); + foo(require('m3')); + var z = { f: require('m4') } + `, + /* readImports */true, + /* detectJavaScriptImports */ true, + { + referencedFiles: [], + importedFiles: [ + { fileName: "m1", pos: 39, end: 41 }, + { fileName: "m2", pos: 74, end: 76 }, + { fileName: "m3", pos: 105, end: 107 }, + { fileName: "m4", pos: 146, end: 148 }, + ], + ambientExternalModules: undefined, + isLibFile: false + }) + }); + it("Correctly handles dependency lists in define([deplist]) calls in JavaScript files", function () { + test(` + define(["mod1", "mod2"], (m1, m2) => { + }); + `, + /* readImports */true, + /* detectJavaScriptImports */ true, + { + referencedFiles: [], + importedFiles: [ + { fileName: "mod1", pos: 21, end: 25 }, + { fileName: "mod2", pos: 29, end: 33 }, + ], + ambientExternalModules: undefined, + isLibFile: false + }) + }); + it("Correctly handles dependency lists in define(modName, [deplist]) calls in JavaScript files", function () { + test(` + define("mod", ["mod1", "mod2"], (m1, m2) => { + }); + `, + /* readImports */true, + /* detectJavaScriptImports */ true, + { + referencedFiles: [], + importedFiles: [ + { fileName: "mod1", pos: 28, end: 32 }, + { fileName: "mod2", pos: 36, end: 40 }, + ], + ambientExternalModules: undefined, + isLibFile: false + }) + }); + it("Excludes require/exports/module names from dependency lists in define(modName, [deplist]) calls in JavaScript files", function () { + test(` + define(["require", "exports", "module", "mod1", "mod2"], (m1, m2) => { + }); + `, + /* readImports */true, + /* detectJavaScriptImports */ true, + { + referencedFiles: [], + importedFiles: [ + { fileName: "mod1", pos: 53, end: 57 }, + { fileName: "mod2", pos: 61, end: 65 }, + ], + ambientExternalModules: undefined, + isLibFile: false + }); + test(` + define(["require", "exports", "mod1", "module"], (m1, m2) => { + }); + `, + /* readImports */true, + /* detectJavaScriptImports */ true, + { + referencedFiles: [], + importedFiles: [ + { fileName: "mod1", pos: 43, end: 47 }, + { fileName: "module", pos: 51, end: 57 }, + ], + ambientExternalModules: undefined, + isLibFile: false + }); + test(` + define(["require", "require", "exports"], (m1, m2) => { + }); + `, + /* readImports */true, + /* detectJavaScriptImports */ true, + { + referencedFiles: [], + importedFiles: [ + { fileName: "require", pos: 32, end: 39 }, + { fileName: "exports", pos: 43, end: 50 }, + ], + ambientExternalModules: undefined, + isLibFile: false + }); + }); }); }); diff --git a/tests/webTestServer.ts b/tests/webTestServer.ts index 6d3144eeaec52..75d90dbeefeb8 100644 --- a/tests/webTestServer.ts +++ b/tests/webTestServer.ts @@ -5,6 +5,7 @@ import fs = require("fs"); import path = require("path"); import url = require("url"); import child_process = require("child_process"); +import os = require("os"); /// Command line processing /// @@ -263,7 +264,19 @@ http.createServer(function (req: http.ServerRequest, res: http.ServerResponse) { var browserPath: string; if ((browser && browser === 'chrome')) { - var defaultChromePath = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"; + const platform = os.platform(); + let defaultChromePath: string; + switch(platform) { + case "win32": + defaultChromePath = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"; + break; + case "linux": + defaultChromePath = "/opt/google/chrome/chrome"; + break; + default: + console.log(`Default Chrome location for platform ${platform} is unknown`); + break; + } if (fs.existsSync(defaultChromePath)) { browserPath = defaultChromePath; } else { From 2f7719b61d3d97659a1bf430c4e48bf7897a3c0b Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 16 Oct 2015 16:40:04 -0700 Subject: [PATCH 02/10] Address CR feedback --- src/compiler/binder.ts | 22 +++++++++--------- src/compiler/checker.ts | 24 ++++++-------------- tests/cases/fourslash/javaScriptModules13.ts | 3 --- 3 files changed, 18 insertions(+), 31 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 4e0d5225f58ed..d5ab7dd11ca9c 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -166,13 +166,12 @@ namespace ts { return "__export"; case SyntaxKind.ExportAssignment: return (node).isExportEquals ? "export=" : "default"; + case SyntaxKind.BinaryExpression: + // Binary expression case is for JS module 'module.exports = expr' + return "export="; case SyntaxKind.FunctionDeclaration: case SyntaxKind.ClassDeclaration: return node.flags & NodeFlags.Default ? "default" : undefined; - - case SyntaxKind.BinaryExpression: - Debug.assert(isModuleExportsAssignment(node)); - return "__jsExports"; } } @@ -936,9 +935,7 @@ namespace ts { return bindAnonymousDeclaration(node, SymbolFlags.Function, bindingName); case SyntaxKind.CallExpression: - // We're only inspecting call expressions to detect CommonJS modules, so we can skip - // this check if we've already seen the module indicator - if (isJavaScriptFile && !file.commonJsModuleIndicator) { + if (isJavaScriptFile) { bindCallExpression(node); } break; @@ -984,12 +981,13 @@ namespace ts { bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName) }"`); } - function bindExportAssignment(node: ExportAssignment) { + function bindExportAssignment(node: ExportAssignment|BinaryExpression) { + let boundExpression = node.kind === SyntaxKind.ExportAssignment ? (node).expression : (node).right; if (!container.symbol || !container.symbol.exports) { // Export assignment in some sort of block construct bindAnonymousDeclaration(node, SymbolFlags.Alias, getDeclarationName(node)); } - else if (node.expression.kind === SyntaxKind.Identifier) { + else if (boundExpression.kind === SyntaxKind.Identifier) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Alias, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes); } @@ -1033,11 +1031,13 @@ namespace ts { function bindModuleExportsAssignment(node: BinaryExpression) { // 'module.exports = expr' assignment setCommonJsModuleIndicator(node); - declareSymbol(file.symbol.exports, file.symbol, node, SymbolFlags.None, SymbolFlags.None); + bindExportAssignment(node); } function bindCallExpression(node: CallExpression) { - if (isRequireCall(node)) { + // We're only inspecting call expressions to detect CommonJS modules, so we can skip + // this check if we've already seen the module indicator + if (!file.commonJsModuleIndicator && isRequireCall(node)) { setCommonJsModuleIndicator(node); } } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7e15f0a3ad033..f0c81940192ae 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1087,20 +1087,6 @@ namespace ts { visit(resolveExternalModuleName(node, (node).moduleSpecifier)); } } - - // CommonJS 'module.exports = expr' assignments - let commonJsModuleExports = symbol.exports["__jsExports"]; - if (commonJsModuleExports) { - for (var i = 0; i < commonJsModuleExports.declarations.length; i++) { - let properties = getPropertiesOfType(checkExpression((commonJsModuleExports.declarations[i]).right)); - if (i === 0) { - result = createSymbolTable(properties); - } - else { - mergeSymbolTable(result, createSymbolTable(properties)); - } - } - } } } } @@ -2586,6 +2572,10 @@ namespace ts { if (declaration.kind === SyntaxKind.ExportAssignment) { return links.type = checkExpression((declaration).expression); } + // Handle module.exports = expr + if (declaration.kind === SyntaxKind.BinaryExpression) { + return links.type = checkExpression((declaration).right); + } // Handle exports.p = expr if (declaration.kind === SyntaxKind.PropertyAccessExpression && declaration.parent.kind === SyntaxKind.BinaryExpression) { return checkExpressionCached((declaration.parent).right); @@ -3839,9 +3829,9 @@ namespace ts { function resolveExternalModuleTypeByLiteral(name: StringLiteral) { let moduleSym = resolveExternalModuleName(name, name); if (moduleSym) { - let moduleSymSym = resolveExternalModuleSymbol(moduleSym); - if (moduleSymSym) { - return getTypeOfSymbol(moduleSymSym); + let resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); + if (resolvedModuleSymbol) { + return getTypeOfSymbol(resolvedModuleSymbol); } } diff --git a/tests/cases/fourslash/javaScriptModules13.ts b/tests/cases/fourslash/javaScriptModules13.ts index 215f47e9ad61a..8b22971009cf4 100644 --- a/tests/cases/fourslash/javaScriptModules13.ts +++ b/tests/cases/fourslash/javaScriptModules13.ts @@ -6,8 +6,6 @@ // @Filename: myMod.js //// if (true) { //// module.exports = { a: 10 }; -//// } else { -//// module.exports = { b: 10 }; //// } //// var invisible = true; @@ -26,4 +24,3 @@ verify.not.completionListContains('invisible'); edit.insert('x.'); verify.completionListContains('a'); -verify.completionListContains('b'); From 61b71008d71be7c65c3c75657c85875b810b1482 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 16 Oct 2015 17:35:43 -0700 Subject: [PATCH 03/10] Remove obsolute AMD logic from reference preprocessing in services --- src/services/services.ts | 16 +------ .../unittests/services/preProcessFile.ts | 48 ------------------- 2 files changed, 1 insertion(+), 63 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index a6611a3d39a57..30d993cb6b634 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2351,21 +2351,7 @@ namespace ts { while (token !== SyntaxKind.CloseBracketToken && token !== SyntaxKind.EndOfFileToken) { // record string literals as module names if (token === SyntaxKind.StringLiteral) { - const moduleName = scanner.getTokenValue(); - // record first item in the list only if its name is not "require" - // record second item in the list only if its name is not "exports" - // record third item in the list only if its name is not "module" - // record all other items in the list unconditionally - const shouldRecordName = - i === 0 - ? moduleName !== "require" - : i === 1 - ? moduleName !== "exports" - : i !== 2 || moduleName !== "module"; - - if (shouldRecordName) { - recordModuleName(); - } + recordModuleName(); i++; } diff --git a/tests/cases/unittests/services/preProcessFile.ts b/tests/cases/unittests/services/preProcessFile.ts index aba5ce15c0392..d9ddaf0f256b5 100644 --- a/tests/cases/unittests/services/preProcessFile.ts +++ b/tests/cases/unittests/services/preProcessFile.ts @@ -262,54 +262,6 @@ describe('PreProcessFile:', function () { isLibFile: false }) }); - it("Excludes require/exports/module names from dependency lists in define(modName, [deplist]) calls in JavaScript files", function () { - test(` - define(["require", "exports", "module", "mod1", "mod2"], (m1, m2) => { - }); - `, - /* readImports */true, - /* detectJavaScriptImports */ true, - { - referencedFiles: [], - importedFiles: [ - { fileName: "mod1", pos: 53, end: 57 }, - { fileName: "mod2", pos: 61, end: 65 }, - ], - ambientExternalModules: undefined, - isLibFile: false - }); - - test(` - define(["require", "exports", "mod1", "module"], (m1, m2) => { - }); - `, - /* readImports */true, - /* detectJavaScriptImports */ true, - { - referencedFiles: [], - importedFiles: [ - { fileName: "mod1", pos: 43, end: 47 }, - { fileName: "module", pos: 51, end: 57 }, - ], - ambientExternalModules: undefined, - isLibFile: false - }); - test(` - define(["require", "require", "exports"], (m1, m2) => { - }); - `, - /* readImports */true, - /* detectJavaScriptImports */ true, - { - referencedFiles: [], - importedFiles: [ - { fileName: "require", pos: 32, end: 39 }, - { fileName: "exports", pos: 43, end: 50 }, - ], - ambientExternalModules: undefined, - isLibFile: false - }); - }); }); }); From 5725fc4497d2aa2d0711cd2918ddde62f43cedff Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 19 Oct 2015 11:02:20 -0700 Subject: [PATCH 04/10] CR feedback --- lib/lib.core.d.ts | 16 ---- lib/lib.core.es6.d.ts | 45 ++++++---- lib/lib.d.ts | 168 ++++++-------------------------------- lib/lib.dom.d.ts | 152 ++++++---------------------------- lib/lib.es6.d.ts | 168 ++++++-------------------------------- lib/lib.webworker.d.ts | 7 +- src/compiler/checker.ts | 18 +--- src/compiler/utilities.ts | 5 +- src/lib/core.d.ts | 16 ---- 9 files changed, 119 insertions(+), 476 deletions(-) diff --git a/lib/lib.core.d.ts b/lib/lib.core.d.ts index c1a71dd8d1da8..b588c9fdb77ee 100644 --- a/lib/lib.core.d.ts +++ b/lib/lib.core.d.ts @@ -1198,22 +1198,6 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } - -declare namespace CommonJS { - export var require: Require; - - export var exports: any; - - interface Exports { } - interface Module { - exports: Exports; - } - - interface Require { - (moduleName: string): any; - } -} - interface ArrayLike { length: number; [n: number]: T; diff --git a/lib/lib.core.es6.d.ts b/lib/lib.core.es6.d.ts index b0d4120b4b96e..6d6a68559f864 100644 --- a/lib/lib.core.es6.d.ts +++ b/lib/lib.core.es6.d.ts @@ -1198,22 +1198,6 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } - -declare namespace CommonJS { - export var require: Require; - - export var exports: any; - - interface Exports { } - interface Module { - exports: Exports; - } - - interface Require { - (moduleName: string): any; - } -} - interface ArrayLike { length: number; [n: number]: T; @@ -3981,7 +3965,34 @@ interface ObjectConstructor { * Copy the values of all of the enumerable own properties from one or more source objects to a * target object. Returns the target object. * @param target The target object to copy to. - * @param sources One or more source objects to copy properties from. + * @param source The source object from which to copy properties. + */ + assign(target: T, source: U): T & U; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source1 The first source object from which to copy properties. + * @param source2 The second source object from which to copy properties. + */ + assign(target: T, source1: U, source2: V): T & U & V; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source1 The first source object from which to copy properties. + * @param source2 The second source object from which to copy properties. + * @param source3 The third source object from which to copy properties. + */ + assign(target: T, source1: U, source2: V, source3: W): T & U & V & W; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param sources One or more source objects from which to copy properties */ assign(target: any, ...sources: any[]): any; diff --git a/lib/lib.d.ts b/lib/lib.d.ts index 450f79b36e9ea..40a29796586d5 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -1198,22 +1198,6 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } - -declare namespace CommonJS { - export var require: Require; - - export var exports: any; - - interface Exports { } - interface Module { - exports: Exports; - } - - interface Require { - (moduleName: string): any; - } -} - interface ArrayLike { length: number; [n: number]: T; @@ -4259,8 +4243,8 @@ interface AnalyserNode extends AudioNode { smoothingTimeConstant: number; getByteFrequencyData(array: Uint8Array): void; getByteTimeDomainData(array: Uint8Array): void; - getFloatFrequencyData(array: any): void; - getFloatTimeDomainData(array: any): void; + getFloatFrequencyData(array: Float32Array): void; + getFloatTimeDomainData(array: Float32Array): void; } declare var AnalyserNode: { @@ -4347,7 +4331,7 @@ interface AudioBuffer { length: number; numberOfChannels: number; sampleRate: number; - getChannelData(channel: number): any; + getChannelData(channel: number): Float32Array; } declare var AudioBuffer: { @@ -4391,7 +4375,7 @@ interface AudioContext extends EventTarget { createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; createOscillator(): OscillatorNode; createPanner(): PannerNode; - createPeriodicWave(real: any, imag: any): PeriodicWave; + createPeriodicWave(real: Float32Array, imag: Float32Array): PeriodicWave; createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; createStereoPanner(): StereoPannerNode; createWaveShaper(): WaveShaperNode; @@ -4449,7 +4433,7 @@ interface AudioParam { linearRampToValueAtTime(value: number, endTime: number): void; setTargetAtTime(target: number, startTime: number, timeConstant: number): void; setValueAtTime(value: number, startTime: number): void; - setValueCurveAtTime(values: any, startTime: number, duration: number): void; + setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): void; } declare var AudioParam: { @@ -4525,7 +4509,7 @@ interface BiquadFilterNode extends AudioNode { frequency: AudioParam; gain: AudioParam; type: string; - getFrequencyResponse(frequencyHz: any, magResponse: any, phaseResponse: any): void; + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; } declare var BiquadFilterNode: { @@ -5124,7 +5108,7 @@ declare var CanvasPattern: { interface CanvasRenderingContext2D { canvas: HTMLCanvasElement; - fillStyle: any; + fillStyle: string | CanvasGradient | CanvasPattern; font: string; globalAlpha: number; globalCompositeOperation: string; @@ -5139,7 +5123,7 @@ interface CanvasRenderingContext2D { shadowColor: string; shadowOffsetX: number; shadowOffsetY: number; - strokeStyle: any; + strokeStyle: string | CanvasGradient | CanvasPattern; textAlign: string; textBaseline: string; arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; @@ -6507,8 +6491,6 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven importNode(importedNode: Node, deep: boolean): Node; msElementsFromPoint(x: number, y: number): NodeList; msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; - msGetPrintDocumentForNamedFlow(flowName: string): Document; - msSetPrintDocumentUriForNamedFlow(flowName: string, uri: string): void; /** * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. * @param url Specifies a MIME type for the document. @@ -11330,27 +11312,6 @@ declare var MSHTMLWebViewElement: { new(): MSHTMLWebViewElement; } -interface MSHeaderFooter { - URL: string; - dateLong: string; - dateShort: string; - font: string; - htmlFoot: string; - htmlHead: string; - page: number; - pageTotal: number; - textFoot: string; - textHead: string; - timeLong: string; - timeShort: string; - title: string; -} - -declare var MSHeaderFooter: { - prototype: MSHeaderFooter; - new(): MSHeaderFooter; -} - interface MSInputMethodContext extends EventTarget { compositionEndOffset: number; compositionStartOffset: number; @@ -11509,24 +11470,6 @@ declare var MSPointerEvent: { new(typeArg: string, eventInitDict?: PointerEventInit): MSPointerEvent; } -interface MSPrintManagerTemplatePrinter extends MSTemplatePrinter, EventTarget { - percentScale: number; - showHeaderFooter: boolean; - shrinkToFit: boolean; - drawPreviewPage(element: HTMLElement, pageNumber: number): void; - endPrint(): void; - getPrintTaskOptionValue(key: string): any; - invalidatePreview(): void; - setPageCount(pageCount: number): void; - startPrint(): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var MSPrintManagerTemplatePrinter: { - prototype: MSPrintManagerTemplatePrinter; - new(): MSPrintManagerTemplatePrinter; -} - interface MSRangeCollection { length: number; item(index: number): Range; @@ -11574,63 +11517,6 @@ declare var MSStreamReader: { new(): MSStreamReader; } -interface MSTemplatePrinter { - collate: boolean; - copies: number; - currentPage: boolean; - currentPageAvail: boolean; - duplex: boolean; - footer: string; - frameActive: boolean; - frameActiveEnabled: boolean; - frameAsShown: boolean; - framesetDocument: boolean; - header: string; - headerFooterFont: string; - marginBottom: number; - marginLeft: number; - marginRight: number; - marginTop: number; - orientation: string; - pageFrom: number; - pageHeight: number; - pageTo: number; - pageWidth: number; - selectedPages: boolean; - selection: boolean; - selectionEnabled: boolean; - unprintableBottom: number; - unprintableLeft: number; - unprintableRight: number; - unprintableTop: number; - usePrinterCopyCollate: boolean; - createHeaderFooter(): MSHeaderFooter; - deviceSupports(property: string): any; - ensurePrintDialogDefaults(): boolean; - getPageMarginBottom(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginBottomImportant(pageRule: CSSPageRule): boolean; - getPageMarginLeft(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginLeftImportant(pageRule: CSSPageRule): boolean; - getPageMarginRight(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginRightImportant(pageRule: CSSPageRule): boolean; - getPageMarginTop(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginTopImportant(pageRule: CSSPageRule): boolean; - printBlankPage(): void; - printNonNative(document: any): boolean; - printNonNativeFrames(document: any, activeFrame: boolean): void; - printPage(element: HTMLElement): void; - showPageSetupDialog(): boolean; - showPrintDialog(): boolean; - startDoc(title: string): boolean; - stopDoc(): void; - updatePageStatus(status: number): void; -} - -declare var MSTemplatePrinter: { - prototype: MSTemplatePrinter; - new(): MSTemplatePrinter; -} - interface MSWebViewAsyncOperation extends EventTarget { error: DOMError; oncomplete: (ev: Event) => any; @@ -12048,6 +11934,10 @@ declare var Node: { } interface NodeFilter { + acceptNode(n: Node): number; +} + +declare var NodeFilter: { FILTER_ACCEPT: number; FILTER_REJECT: number; FILTER_SKIP: number; @@ -12065,7 +11955,6 @@ interface NodeFilter { SHOW_PROCESSING_INSTRUCTION: number; SHOW_TEXT: number; } -declare var NodeFilter: NodeFilter; interface NodeIterator { expandEntityReferences: boolean; @@ -12775,7 +12664,6 @@ declare var SVGDescElement: { interface SVGElement extends Element { id: string; - className: any; onclick: (ev: MouseEvent) => any; ondblclick: (ev: MouseEvent) => any; onfocusin: (ev: FocusEvent) => any; @@ -12789,6 +12677,7 @@ interface SVGElement extends Element { ownerSVGElement: SVGSVGElement; viewportElement: SVGElement; xmlbase: string; + className: any; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -14950,7 +14839,7 @@ declare var WEBGL_depth_texture: { } interface WaveShaperNode extends AudioNode { - curve: any; + curve: Float32Array; oversample: string; } @@ -15137,34 +15026,34 @@ interface WebGLRenderingContext { texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void; texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void; uniform1f(location: WebGLUniformLocation, x: number): void; - uniform1fv(location: WebGLUniformLocation, v: any): void; + uniform1fv(location: WebGLUniformLocation, v: Float32Array): void; uniform1i(location: WebGLUniformLocation, x: number): void; uniform1iv(location: WebGLUniformLocation, v: Int32Array): void; uniform2f(location: WebGLUniformLocation, x: number, y: number): void; - uniform2fv(location: WebGLUniformLocation, v: any): void; + uniform2fv(location: WebGLUniformLocation, v: Float32Array): void; uniform2i(location: WebGLUniformLocation, x: number, y: number): void; uniform2iv(location: WebGLUniformLocation, v: Int32Array): void; uniform3f(location: WebGLUniformLocation, x: number, y: number, z: number): void; - uniform3fv(location: WebGLUniformLocation, v: any): void; + uniform3fv(location: WebGLUniformLocation, v: Float32Array): void; uniform3i(location: WebGLUniformLocation, x: number, y: number, z: number): void; uniform3iv(location: WebGLUniformLocation, v: Int32Array): void; uniform4f(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; - uniform4fv(location: WebGLUniformLocation, v: any): void; + uniform4fv(location: WebGLUniformLocation, v: Float32Array): void; uniform4i(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; uniform4iv(location: WebGLUniformLocation, v: Int32Array): void; - uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; - uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; - uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; useProgram(program: WebGLProgram): void; validateProgram(program: WebGLProgram): void; vertexAttrib1f(indx: number, x: number): void; - vertexAttrib1fv(indx: number, values: any): void; + vertexAttrib1fv(indx: number, values: Float32Array): void; vertexAttrib2f(indx: number, x: number, y: number): void; - vertexAttrib2fv(indx: number, values: any): void; + vertexAttrib2fv(indx: number, values: Float32Array): void; vertexAttrib3f(indx: number, x: number, y: number, z: number): void; - vertexAttrib3fv(indx: number, values: any): void; + vertexAttrib3fv(indx: number, values: Float32Array): void; vertexAttrib4f(indx: number, x: number, y: number, z: number, w: number): void; - vertexAttrib4fv(indx: number, values: any): void; + vertexAttrib4fv(indx: number, values: Float32Array): void; vertexAttribPointer(indx: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void; viewport(x: number, y: number, width: number, height: number): void; ACTIVE_ATTRIBUTES: number; @@ -15928,7 +15817,6 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window locationbar: BarProp; menubar: BarProp; msAnimationStartTime: number; - msTemplatePrinter: MSTemplatePrinter; name: string; navigator: Navigator; offscreenBuffering: string | boolean; @@ -16665,7 +16553,6 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } - interface NodeListOf extends NodeList { length: number; item(index: number): TNode; @@ -16686,8 +16573,6 @@ interface EventListenerObject { handleEvent(evt: Event): void; } -declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; - interface MessageEventInit extends EventInit { data?: any; origin?: string; @@ -16703,6 +16588,8 @@ interface ProgressEventInit extends EventInit { total?: number; } +declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -16763,7 +16650,6 @@ declare var location: Location; declare var locationbar: BarProp; declare var menubar: BarProp; declare var msAnimationStartTime: number; -declare var msTemplatePrinter: MSTemplatePrinter; declare var name: string; declare var navigator: Navigator; declare var offscreenBuffering: string | boolean; diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index 849560ac0d287..41d569ba9f74a 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -419,8 +419,8 @@ interface AnalyserNode extends AudioNode { smoothingTimeConstant: number; getByteFrequencyData(array: Uint8Array): void; getByteTimeDomainData(array: Uint8Array): void; - getFloatFrequencyData(array: any): void; - getFloatTimeDomainData(array: any): void; + getFloatFrequencyData(array: Float32Array): void; + getFloatTimeDomainData(array: Float32Array): void; } declare var AnalyserNode: { @@ -507,7 +507,7 @@ interface AudioBuffer { length: number; numberOfChannels: number; sampleRate: number; - getChannelData(channel: number): any; + getChannelData(channel: number): Float32Array; } declare var AudioBuffer: { @@ -551,7 +551,7 @@ interface AudioContext extends EventTarget { createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; createOscillator(): OscillatorNode; createPanner(): PannerNode; - createPeriodicWave(real: any, imag: any): PeriodicWave; + createPeriodicWave(real: Float32Array, imag: Float32Array): PeriodicWave; createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; createStereoPanner(): StereoPannerNode; createWaveShaper(): WaveShaperNode; @@ -609,7 +609,7 @@ interface AudioParam { linearRampToValueAtTime(value: number, endTime: number): void; setTargetAtTime(target: number, startTime: number, timeConstant: number): void; setValueAtTime(value: number, startTime: number): void; - setValueCurveAtTime(values: any, startTime: number, duration: number): void; + setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): void; } declare var AudioParam: { @@ -685,7 +685,7 @@ interface BiquadFilterNode extends AudioNode { frequency: AudioParam; gain: AudioParam; type: string; - getFrequencyResponse(frequencyHz: any, magResponse: any, phaseResponse: any): void; + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; } declare var BiquadFilterNode: { @@ -1284,7 +1284,7 @@ declare var CanvasPattern: { interface CanvasRenderingContext2D { canvas: HTMLCanvasElement; - fillStyle: any; + fillStyle: string | CanvasGradient | CanvasPattern; font: string; globalAlpha: number; globalCompositeOperation: string; @@ -1299,7 +1299,7 @@ interface CanvasRenderingContext2D { shadowColor: string; shadowOffsetX: number; shadowOffsetY: number; - strokeStyle: any; + strokeStyle: string | CanvasGradient | CanvasPattern; textAlign: string; textBaseline: string; arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; @@ -2667,8 +2667,6 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven importNode(importedNode: Node, deep: boolean): Node; msElementsFromPoint(x: number, y: number): NodeList; msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; - msGetPrintDocumentForNamedFlow(flowName: string): Document; - msSetPrintDocumentUriForNamedFlow(flowName: string, uri: string): void; /** * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. * @param url Specifies a MIME type for the document. @@ -7490,27 +7488,6 @@ declare var MSHTMLWebViewElement: { new(): MSHTMLWebViewElement; } -interface MSHeaderFooter { - URL: string; - dateLong: string; - dateShort: string; - font: string; - htmlFoot: string; - htmlHead: string; - page: number; - pageTotal: number; - textFoot: string; - textHead: string; - timeLong: string; - timeShort: string; - title: string; -} - -declare var MSHeaderFooter: { - prototype: MSHeaderFooter; - new(): MSHeaderFooter; -} - interface MSInputMethodContext extends EventTarget { compositionEndOffset: number; compositionStartOffset: number; @@ -7669,24 +7646,6 @@ declare var MSPointerEvent: { new(typeArg: string, eventInitDict?: PointerEventInit): MSPointerEvent; } -interface MSPrintManagerTemplatePrinter extends MSTemplatePrinter, EventTarget { - percentScale: number; - showHeaderFooter: boolean; - shrinkToFit: boolean; - drawPreviewPage(element: HTMLElement, pageNumber: number): void; - endPrint(): void; - getPrintTaskOptionValue(key: string): any; - invalidatePreview(): void; - setPageCount(pageCount: number): void; - startPrint(): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var MSPrintManagerTemplatePrinter: { - prototype: MSPrintManagerTemplatePrinter; - new(): MSPrintManagerTemplatePrinter; -} - interface MSRangeCollection { length: number; item(index: number): Range; @@ -7734,63 +7693,6 @@ declare var MSStreamReader: { new(): MSStreamReader; } -interface MSTemplatePrinter { - collate: boolean; - copies: number; - currentPage: boolean; - currentPageAvail: boolean; - duplex: boolean; - footer: string; - frameActive: boolean; - frameActiveEnabled: boolean; - frameAsShown: boolean; - framesetDocument: boolean; - header: string; - headerFooterFont: string; - marginBottom: number; - marginLeft: number; - marginRight: number; - marginTop: number; - orientation: string; - pageFrom: number; - pageHeight: number; - pageTo: number; - pageWidth: number; - selectedPages: boolean; - selection: boolean; - selectionEnabled: boolean; - unprintableBottom: number; - unprintableLeft: number; - unprintableRight: number; - unprintableTop: number; - usePrinterCopyCollate: boolean; - createHeaderFooter(): MSHeaderFooter; - deviceSupports(property: string): any; - ensurePrintDialogDefaults(): boolean; - getPageMarginBottom(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginBottomImportant(pageRule: CSSPageRule): boolean; - getPageMarginLeft(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginLeftImportant(pageRule: CSSPageRule): boolean; - getPageMarginRight(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginRightImportant(pageRule: CSSPageRule): boolean; - getPageMarginTop(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginTopImportant(pageRule: CSSPageRule): boolean; - printBlankPage(): void; - printNonNative(document: any): boolean; - printNonNativeFrames(document: any, activeFrame: boolean): void; - printPage(element: HTMLElement): void; - showPageSetupDialog(): boolean; - showPrintDialog(): boolean; - startDoc(title: string): boolean; - stopDoc(): void; - updatePageStatus(status: number): void; -} - -declare var MSTemplatePrinter: { - prototype: MSTemplatePrinter; - new(): MSTemplatePrinter; -} - interface MSWebViewAsyncOperation extends EventTarget { error: DOMError; oncomplete: (ev: Event) => any; @@ -8208,6 +8110,10 @@ declare var Node: { } interface NodeFilter { + acceptNode(n: Node): number; +} + +declare var NodeFilter: { FILTER_ACCEPT: number; FILTER_REJECT: number; FILTER_SKIP: number; @@ -8225,7 +8131,6 @@ interface NodeFilter { SHOW_PROCESSING_INSTRUCTION: number; SHOW_TEXT: number; } -declare var NodeFilter: NodeFilter; interface NodeIterator { expandEntityReferences: boolean; @@ -8935,7 +8840,6 @@ declare var SVGDescElement: { interface SVGElement extends Element { id: string; - className: any; onclick: (ev: MouseEvent) => any; ondblclick: (ev: MouseEvent) => any; onfocusin: (ev: FocusEvent) => any; @@ -8949,6 +8853,7 @@ interface SVGElement extends Element { ownerSVGElement: SVGSVGElement; viewportElement: SVGElement; xmlbase: string; + className: any; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -11110,7 +11015,7 @@ declare var WEBGL_depth_texture: { } interface WaveShaperNode extends AudioNode { - curve: any; + curve: Float32Array; oversample: string; } @@ -11297,34 +11202,34 @@ interface WebGLRenderingContext { texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void; texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void; uniform1f(location: WebGLUniformLocation, x: number): void; - uniform1fv(location: WebGLUniformLocation, v: any): void; + uniform1fv(location: WebGLUniformLocation, v: Float32Array): void; uniform1i(location: WebGLUniformLocation, x: number): void; uniform1iv(location: WebGLUniformLocation, v: Int32Array): void; uniform2f(location: WebGLUniformLocation, x: number, y: number): void; - uniform2fv(location: WebGLUniformLocation, v: any): void; + uniform2fv(location: WebGLUniformLocation, v: Float32Array): void; uniform2i(location: WebGLUniformLocation, x: number, y: number): void; uniform2iv(location: WebGLUniformLocation, v: Int32Array): void; uniform3f(location: WebGLUniformLocation, x: number, y: number, z: number): void; - uniform3fv(location: WebGLUniformLocation, v: any): void; + uniform3fv(location: WebGLUniformLocation, v: Float32Array): void; uniform3i(location: WebGLUniformLocation, x: number, y: number, z: number): void; uniform3iv(location: WebGLUniformLocation, v: Int32Array): void; uniform4f(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; - uniform4fv(location: WebGLUniformLocation, v: any): void; + uniform4fv(location: WebGLUniformLocation, v: Float32Array): void; uniform4i(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; uniform4iv(location: WebGLUniformLocation, v: Int32Array): void; - uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; - uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; - uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; useProgram(program: WebGLProgram): void; validateProgram(program: WebGLProgram): void; vertexAttrib1f(indx: number, x: number): void; - vertexAttrib1fv(indx: number, values: any): void; + vertexAttrib1fv(indx: number, values: Float32Array): void; vertexAttrib2f(indx: number, x: number, y: number): void; - vertexAttrib2fv(indx: number, values: any): void; + vertexAttrib2fv(indx: number, values: Float32Array): void; vertexAttrib3f(indx: number, x: number, y: number, z: number): void; - vertexAttrib3fv(indx: number, values: any): void; + vertexAttrib3fv(indx: number, values: Float32Array): void; vertexAttrib4f(indx: number, x: number, y: number, z: number, w: number): void; - vertexAttrib4fv(indx: number, values: any): void; + vertexAttrib4fv(indx: number, values: Float32Array): void; vertexAttribPointer(indx: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void; viewport(x: number, y: number, width: number, height: number): void; ACTIVE_ATTRIBUTES: number; @@ -12088,7 +11993,6 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window locationbar: BarProp; menubar: BarProp; msAnimationStartTime: number; - msTemplatePrinter: MSTemplatePrinter; name: string; navigator: Navigator; offscreenBuffering: string | boolean; @@ -12825,7 +12729,6 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } - interface NodeListOf extends NodeList { length: number; item(index: number): TNode; @@ -12846,8 +12749,6 @@ interface EventListenerObject { handleEvent(evt: Event): void; } -declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; - interface MessageEventInit extends EventInit { data?: any; origin?: string; @@ -12863,6 +12764,8 @@ interface ProgressEventInit extends EventInit { total?: number; } +declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -12923,7 +12826,6 @@ declare var location: Location; declare var locationbar: BarProp; declare var menubar: BarProp; declare var msAnimationStartTime: number; -declare var msTemplatePrinter: MSTemplatePrinter; declare var name: string; declare var navigator: Navigator; declare var offscreenBuffering: string | boolean; diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index 63e6a101fbc6e..a7bf8f050764e 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -1198,22 +1198,6 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } - -declare namespace CommonJS { - export var require: Require; - - export var exports: any; - - interface Exports { } - interface Module { - exports: Exports; - } - - interface Require { - (moduleName: string): any; - } -} - interface ArrayLike { length: number; [n: number]: T; @@ -5574,8 +5558,8 @@ interface AnalyserNode extends AudioNode { smoothingTimeConstant: number; getByteFrequencyData(array: Uint8Array): void; getByteTimeDomainData(array: Uint8Array): void; - getFloatFrequencyData(array: any): void; - getFloatTimeDomainData(array: any): void; + getFloatFrequencyData(array: Float32Array): void; + getFloatTimeDomainData(array: Float32Array): void; } declare var AnalyserNode: { @@ -5662,7 +5646,7 @@ interface AudioBuffer { length: number; numberOfChannels: number; sampleRate: number; - getChannelData(channel: number): any; + getChannelData(channel: number): Float32Array; } declare var AudioBuffer: { @@ -5706,7 +5690,7 @@ interface AudioContext extends EventTarget { createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; createOscillator(): OscillatorNode; createPanner(): PannerNode; - createPeriodicWave(real: any, imag: any): PeriodicWave; + createPeriodicWave(real: Float32Array, imag: Float32Array): PeriodicWave; createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; createStereoPanner(): StereoPannerNode; createWaveShaper(): WaveShaperNode; @@ -5764,7 +5748,7 @@ interface AudioParam { linearRampToValueAtTime(value: number, endTime: number): void; setTargetAtTime(target: number, startTime: number, timeConstant: number): void; setValueAtTime(value: number, startTime: number): void; - setValueCurveAtTime(values: any, startTime: number, duration: number): void; + setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): void; } declare var AudioParam: { @@ -5840,7 +5824,7 @@ interface BiquadFilterNode extends AudioNode { frequency: AudioParam; gain: AudioParam; type: string; - getFrequencyResponse(frequencyHz: any, magResponse: any, phaseResponse: any): void; + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; } declare var BiquadFilterNode: { @@ -6439,7 +6423,7 @@ declare var CanvasPattern: { interface CanvasRenderingContext2D { canvas: HTMLCanvasElement; - fillStyle: any; + fillStyle: string | CanvasGradient | CanvasPattern; font: string; globalAlpha: number; globalCompositeOperation: string; @@ -6454,7 +6438,7 @@ interface CanvasRenderingContext2D { shadowColor: string; shadowOffsetX: number; shadowOffsetY: number; - strokeStyle: any; + strokeStyle: string | CanvasGradient | CanvasPattern; textAlign: string; textBaseline: string; arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; @@ -7822,8 +7806,6 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven importNode(importedNode: Node, deep: boolean): Node; msElementsFromPoint(x: number, y: number): NodeList; msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; - msGetPrintDocumentForNamedFlow(flowName: string): Document; - msSetPrintDocumentUriForNamedFlow(flowName: string, uri: string): void; /** * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. * @param url Specifies a MIME type for the document. @@ -12645,27 +12627,6 @@ declare var MSHTMLWebViewElement: { new(): MSHTMLWebViewElement; } -interface MSHeaderFooter { - URL: string; - dateLong: string; - dateShort: string; - font: string; - htmlFoot: string; - htmlHead: string; - page: number; - pageTotal: number; - textFoot: string; - textHead: string; - timeLong: string; - timeShort: string; - title: string; -} - -declare var MSHeaderFooter: { - prototype: MSHeaderFooter; - new(): MSHeaderFooter; -} - interface MSInputMethodContext extends EventTarget { compositionEndOffset: number; compositionStartOffset: number; @@ -12824,24 +12785,6 @@ declare var MSPointerEvent: { new(typeArg: string, eventInitDict?: PointerEventInit): MSPointerEvent; } -interface MSPrintManagerTemplatePrinter extends MSTemplatePrinter, EventTarget { - percentScale: number; - showHeaderFooter: boolean; - shrinkToFit: boolean; - drawPreviewPage(element: HTMLElement, pageNumber: number): void; - endPrint(): void; - getPrintTaskOptionValue(key: string): any; - invalidatePreview(): void; - setPageCount(pageCount: number): void; - startPrint(): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var MSPrintManagerTemplatePrinter: { - prototype: MSPrintManagerTemplatePrinter; - new(): MSPrintManagerTemplatePrinter; -} - interface MSRangeCollection { length: number; item(index: number): Range; @@ -12889,63 +12832,6 @@ declare var MSStreamReader: { new(): MSStreamReader; } -interface MSTemplatePrinter { - collate: boolean; - copies: number; - currentPage: boolean; - currentPageAvail: boolean; - duplex: boolean; - footer: string; - frameActive: boolean; - frameActiveEnabled: boolean; - frameAsShown: boolean; - framesetDocument: boolean; - header: string; - headerFooterFont: string; - marginBottom: number; - marginLeft: number; - marginRight: number; - marginTop: number; - orientation: string; - pageFrom: number; - pageHeight: number; - pageTo: number; - pageWidth: number; - selectedPages: boolean; - selection: boolean; - selectionEnabled: boolean; - unprintableBottom: number; - unprintableLeft: number; - unprintableRight: number; - unprintableTop: number; - usePrinterCopyCollate: boolean; - createHeaderFooter(): MSHeaderFooter; - deviceSupports(property: string): any; - ensurePrintDialogDefaults(): boolean; - getPageMarginBottom(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginBottomImportant(pageRule: CSSPageRule): boolean; - getPageMarginLeft(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginLeftImportant(pageRule: CSSPageRule): boolean; - getPageMarginRight(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginRightImportant(pageRule: CSSPageRule): boolean; - getPageMarginTop(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginTopImportant(pageRule: CSSPageRule): boolean; - printBlankPage(): void; - printNonNative(document: any): boolean; - printNonNativeFrames(document: any, activeFrame: boolean): void; - printPage(element: HTMLElement): void; - showPageSetupDialog(): boolean; - showPrintDialog(): boolean; - startDoc(title: string): boolean; - stopDoc(): void; - updatePageStatus(status: number): void; -} - -declare var MSTemplatePrinter: { - prototype: MSTemplatePrinter; - new(): MSTemplatePrinter; -} - interface MSWebViewAsyncOperation extends EventTarget { error: DOMError; oncomplete: (ev: Event) => any; @@ -13363,6 +13249,10 @@ declare var Node: { } interface NodeFilter { + acceptNode(n: Node): number; +} + +declare var NodeFilter: { FILTER_ACCEPT: number; FILTER_REJECT: number; FILTER_SKIP: number; @@ -13380,7 +13270,6 @@ interface NodeFilter { SHOW_PROCESSING_INSTRUCTION: number; SHOW_TEXT: number; } -declare var NodeFilter: NodeFilter; interface NodeIterator { expandEntityReferences: boolean; @@ -14090,7 +13979,6 @@ declare var SVGDescElement: { interface SVGElement extends Element { id: string; - className: any; onclick: (ev: MouseEvent) => any; ondblclick: (ev: MouseEvent) => any; onfocusin: (ev: FocusEvent) => any; @@ -14104,6 +13992,7 @@ interface SVGElement extends Element { ownerSVGElement: SVGSVGElement; viewportElement: SVGElement; xmlbase: string; + className: any; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -16265,7 +16154,7 @@ declare var WEBGL_depth_texture: { } interface WaveShaperNode extends AudioNode { - curve: any; + curve: Float32Array; oversample: string; } @@ -16452,34 +16341,34 @@ interface WebGLRenderingContext { texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void; texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void; uniform1f(location: WebGLUniformLocation, x: number): void; - uniform1fv(location: WebGLUniformLocation, v: any): void; + uniform1fv(location: WebGLUniformLocation, v: Float32Array): void; uniform1i(location: WebGLUniformLocation, x: number): void; uniform1iv(location: WebGLUniformLocation, v: Int32Array): void; uniform2f(location: WebGLUniformLocation, x: number, y: number): void; - uniform2fv(location: WebGLUniformLocation, v: any): void; + uniform2fv(location: WebGLUniformLocation, v: Float32Array): void; uniform2i(location: WebGLUniformLocation, x: number, y: number): void; uniform2iv(location: WebGLUniformLocation, v: Int32Array): void; uniform3f(location: WebGLUniformLocation, x: number, y: number, z: number): void; - uniform3fv(location: WebGLUniformLocation, v: any): void; + uniform3fv(location: WebGLUniformLocation, v: Float32Array): void; uniform3i(location: WebGLUniformLocation, x: number, y: number, z: number): void; uniform3iv(location: WebGLUniformLocation, v: Int32Array): void; uniform4f(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; - uniform4fv(location: WebGLUniformLocation, v: any): void; + uniform4fv(location: WebGLUniformLocation, v: Float32Array): void; uniform4i(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; uniform4iv(location: WebGLUniformLocation, v: Int32Array): void; - uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; - uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; - uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; useProgram(program: WebGLProgram): void; validateProgram(program: WebGLProgram): void; vertexAttrib1f(indx: number, x: number): void; - vertexAttrib1fv(indx: number, values: any): void; + vertexAttrib1fv(indx: number, values: Float32Array): void; vertexAttrib2f(indx: number, x: number, y: number): void; - vertexAttrib2fv(indx: number, values: any): void; + vertexAttrib2fv(indx: number, values: Float32Array): void; vertexAttrib3f(indx: number, x: number, y: number, z: number): void; - vertexAttrib3fv(indx: number, values: any): void; + vertexAttrib3fv(indx: number, values: Float32Array): void; vertexAttrib4f(indx: number, x: number, y: number, z: number, w: number): void; - vertexAttrib4fv(indx: number, values: any): void; + vertexAttrib4fv(indx: number, values: Float32Array): void; vertexAttribPointer(indx: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void; viewport(x: number, y: number, width: number, height: number): void; ACTIVE_ATTRIBUTES: number; @@ -17243,7 +17132,6 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window locationbar: BarProp; menubar: BarProp; msAnimationStartTime: number; - msTemplatePrinter: MSTemplatePrinter; name: string; navigator: Navigator; offscreenBuffering: string | boolean; @@ -17980,7 +17868,6 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } - interface NodeListOf extends NodeList { length: number; item(index: number): TNode; @@ -18001,8 +17888,6 @@ interface EventListenerObject { handleEvent(evt: Event): void; } -declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; - interface MessageEventInit extends EventInit { data?: any; origin?: string; @@ -18018,6 +17903,8 @@ interface ProgressEventInit extends EventInit { total?: number; } +declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -18078,7 +17965,6 @@ declare var location: Location; declare var locationbar: BarProp; declare var menubar: BarProp; declare var msAnimationStartTime: number; -declare var msTemplatePrinter: MSTemplatePrinter; declare var name: string; declare var navigator: Navigator; declare var offscreenBuffering: string | boolean; diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts index 85bcfb1498eed..7995a03a40f5e 100644 --- a/lib/lib.webworker.d.ts +++ b/lib/lib.webworker.d.ts @@ -234,7 +234,7 @@ interface AudioBuffer { length: number; numberOfChannels: number; sampleRate: number; - getChannelData(channel: number): any; + getChannelData(channel: number): Float32Array; } declare var AudioBuffer: { @@ -1111,7 +1111,6 @@ interface WorkerUtils extends Object, WindowBase64 { setTimeout(handler: any, timeout?: any, ...args: any[]): number; } - interface BlobPropertyBag { type?: string; endings?: string; @@ -1126,8 +1125,6 @@ interface EventListenerObject { handleEvent(evt: Event): void; } -declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; - interface MessageEventInit extends EventInit { data?: any; origin?: string; @@ -1143,6 +1140,8 @@ interface ProgressEventInit extends EventInit { total?: number; } +declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f0c81940192ae..aa3e9b4481581 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2577,7 +2577,7 @@ namespace ts { return links.type = checkExpression((declaration).right); } // Handle exports.p = expr - if (declaration.kind === SyntaxKind.PropertyAccessExpression && declaration.parent.kind === SyntaxKind.BinaryExpression) { + if (declaration.kind === SyntaxKind.PropertyAccessExpression) { return checkExpressionCached((declaration.parent).right); } // Handle variable, parameter or property @@ -9377,11 +9377,9 @@ namespace ts { } } - let exprType = checkExpression(node.expression); - if (exprType === cjsRequireType) { - if (node.arguments.length === 1 && node.arguments[0].kind === SyntaxKind.StringLiteral) { - return resolveExternalModuleTypeByLiteral(node.arguments[0]); - } + // In JavaScript files, calls to any identifier 'require' are treated as external module imports + if (isInJavaScriptFile(node) && isRequireCall(node)) { + return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); @@ -14925,14 +14923,6 @@ namespace ts { } }); - // Initialize special symbols - if (compilerOptions.allowNonTsExtensions) { - let req = getExportedSymbolFromNamespace("CommonJS", "require"); - if (req) { - globals["require"] = req; - } - } - getSymbolLinks(undefinedSymbol).type = undefinedType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); getSymbolLinks(unknownSymbol).type = unknownType; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index c5dfcf8947e91..1c875ec1b51aa 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1039,7 +1039,7 @@ namespace ts { return isInJavaScriptFile(file); } - function isInJavaScriptFile(node: Node): boolean { + export function isInJavaScriptFile(node: Node): boolean { return node && !!(node.parserContextFlags & ParserContextFlags.JavaScriptFile); } @@ -1053,7 +1053,8 @@ namespace ts { return expression.kind === SyntaxKind.CallExpression && (expression).expression.kind === SyntaxKind.Identifier && ((expression).expression).text === "require" && - (expression).arguments.length === 1; + (expression).arguments.length === 1 && + (expression).arguments[0].kind === SyntaxKind.StringLiteral; } /** diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts index 86dee00638d19..7259ff5081c31 100644 --- a/src/lib/core.d.ts +++ b/src/lib/core.d.ts @@ -1183,22 +1183,6 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } - -declare namespace CommonJS { - export var require: Require; - - export var exports: any; - - interface Exports { } - interface Module { - exports: Exports; - } - - interface Require { - (moduleName: string): any; - } -} - interface ArrayLike { length: number; [n: number]: T; From efa63b98bb529ee9cb35a04d9adbe76a453de81f Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 19 Oct 2015 11:02:27 -0700 Subject: [PATCH 05/10] LKG update --- lib/tsc.js | 16867 ++++++++++++++++++---------------- lib/tsserver.js | 10067 ++++++++++---------- lib/typescript.d.ts | 527 +- lib/typescript.js | 11716 ++++++++++++----------- lib/typescriptServices.d.ts | 527 +- lib/typescriptServices.js | 11716 ++++++++++++----------- 6 files changed, 27292 insertions(+), 24128 deletions(-) diff --git a/lib/tsc.js b/lib/tsc.js index a4c2586f0418d..ed982c2d9410d 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -410,8 +410,11 @@ var ts; } ts.chainDiagnosticMessages = chainDiagnosticMessages; function concatenateDiagnosticMessageChains(headChain, tailChain) { - Debug.assert(!headChain.next); - headChain.next = tailChain; + var lastChain = headChain; + while (lastChain.next) { + lastChain = lastChain.next; + } + lastChain.next = tailChain; return headChain; } ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; @@ -950,10 +953,14 @@ var ts; close: function () { _fs.unwatchFile(fileName, fileChanged); } }; function fileChanged(curr, prev) { + if (curr.mtime.getTime() === 0) { + callback(fileName, true); + return; + } if (+curr.mtime <= +prev.mtime) { return; } - callback(fileName); + callback(fileName, false); } }, resolvePath: function (path) { @@ -1051,7 +1058,7 @@ var ts; Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum member must have initializer." }, _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, - 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." }, + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In ambient enum declarations member initializer must be constant expression." }, 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_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, @@ -1139,7 +1146,7 @@ var ts; 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." }, - An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, + An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1183, 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." }, @@ -1157,10 +1164,9 @@ var ts; 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." }, - 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_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' 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." }, + Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." }, + Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." }, + Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es6' when targeting 'ES5' or lower." }, 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." }, Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, @@ -1189,10 +1195,6 @@ var ts; An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, - Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning: { code: 1236, category: ts.DiagnosticCategory.Error, key: "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning." }, - with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, - await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, - Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, @@ -1203,6 +1205,10 @@ var ts; _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." }, Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." }, Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method '{0}' cannot have an implementation because it is marked abstract." }, + with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, + await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, + Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, + can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "'=' can only be used in an object literal property inside a destructuring assignment." }, 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." }, @@ -1327,7 +1333,7 @@ var ts; 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_namespace_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 namespace declaration cannot be in a different file from a class or function with which it is merged" }, A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules." }, + Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules or namespaces." }, Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient 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}'" }, @@ -1415,6 +1421,9 @@ var ts; yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." }, + A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A 'this' type is available only in a non-static member of a class or interface." }, + The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, + A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A module cannot have multiple default exports." }, JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -1515,7 +1524,7 @@ var ts; Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, - A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, 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." }, @@ -1527,7 +1536,7 @@ var ts; 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_amd_system_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'" }, + Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es6'" }, 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." }, @@ -1548,7 +1557,7 @@ var ts; 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_amd_system_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'." }, + Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es6'." }, 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}'." }, @@ -1569,7 +1578,6 @@ var ts; Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, - Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, @@ -1616,81 +1624,83 @@ var ts; Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" }, + An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, + A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." } }; })(ts || (ts = {})); var ts; (function (ts) { function tokenIsIdentifierOrKeyword(token) { - return token >= 67; + return token >= 69; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = { - "abstract": 113, - "any": 115, - "as": 114, - "boolean": 118, - "break": 68, - "case": 69, - "catch": 70, - "class": 71, - "continue": 73, - "const": 72, - "constructor": 119, - "debugger": 74, - "declare": 120, - "default": 75, - "delete": 76, - "do": 77, - "else": 78, - "enum": 79, - "export": 80, - "extends": 81, - "false": 82, - "finally": 83, - "for": 84, - "from": 131, - "function": 85, - "get": 121, - "if": 86, - "implements": 104, - "import": 87, - "in": 88, - "instanceof": 89, - "interface": 105, - "is": 122, - "let": 106, - "module": 123, - "namespace": 124, - "new": 90, - "null": 91, - "number": 126, - "package": 107, - "private": 108, - "protected": 109, - "public": 110, - "require": 125, - "return": 92, - "set": 127, - "static": 111, - "string": 128, - "super": 93, - "switch": 94, - "symbol": 129, - "this": 95, - "throw": 96, - "true": 97, - "try": 98, - "type": 130, - "typeof": 99, - "var": 100, - "void": 101, - "while": 102, - "with": 103, - "yield": 112, - "async": 116, - "await": 117, - "of": 132, + "abstract": 115, + "any": 117, + "as": 116, + "boolean": 120, + "break": 70, + "case": 71, + "catch": 72, + "class": 73, + "continue": 75, + "const": 74, + "constructor": 121, + "debugger": 76, + "declare": 122, + "default": 77, + "delete": 78, + "do": 79, + "else": 80, + "enum": 81, + "export": 82, + "extends": 83, + "false": 84, + "finally": 85, + "for": 86, + "from": 133, + "function": 87, + "get": 123, + "if": 88, + "implements": 106, + "import": 89, + "in": 90, + "instanceof": 91, + "interface": 107, + "is": 124, + "let": 108, + "module": 125, + "namespace": 126, + "new": 92, + "null": 93, + "number": 128, + "package": 109, + "private": 110, + "protected": 111, + "public": 112, + "require": 127, + "return": 94, + "set": 129, + "static": 113, + "string": 130, + "super": 95, + "switch": 96, + "symbol": 131, + "this": 97, + "throw": 98, + "true": 99, + "try": 100, + "type": 132, + "typeof": 101, + "var": 102, + "void": 103, + "while": 104, + "with": 105, + "yield": 114, + "async": 118, + "await": 119, + "of": 134, "{": 15, "}": 16, "(": 17, @@ -1712,37 +1722,39 @@ var ts; "=>": 34, "+": 35, "-": 36, + "**": 38, "*": 37, - "/": 38, - "%": 39, - "++": 40, - "--": 41, - "<<": 42, + "/": 39, + "%": 40, + "++": 41, + "--": 42, + "<<": 43, ">": 43, - ">>>": 44, - "&": 45, - "|": 46, - "^": 47, - "!": 48, - "~": 49, - "&&": 50, - "||": 51, - "?": 52, - ":": 53, - "=": 55, - "+=": 56, - "-=": 57, - "*=": 58, - "/=": 59, - "%=": 60, - "<<=": 61, - ">>=": 62, - ">>>=": 63, - "&=": 64, - "|=": 65, - "^=": 66, - "@": 54 + ">>": 44, + ">>>": 45, + "&": 46, + "|": 47, + "^": 48, + "!": 49, + "~": 50, + "&&": 51, + "||": 52, + "?": 53, + ":": 54, + "=": 56, + "+=": 57, + "-=": 58, + "*=": 59, + "**=": 60, + "/=": 61, + "%=": 62, + "<<=": 63, + ">>=": 64, + ">>>=": 65, + "&=": 66, + "|=": 67, + "^=": 68, + "@": 55 }; 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,]; @@ -2144,8 +2156,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 67 || token > 103; }, - isReservedWord: function () { return token >= 68 && token <= 103; }, + isIdentifier: function () { return token === 69 || token > 105; }, + isReservedWord: function () { return token >= 70 && token <= 105; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -2167,16 +2179,6 @@ var ts; onError(message, length || 0); } } - function isIdentifierStart(ch) { - return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || - ch === 36 || ch === 95 || - ch > 127 && isUnicodeIdentifierStart(ch, languageVersion); - } - function isIdentifierPart(ch) { - return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || - ch >= 48 && ch <= 57 || ch === 36 || ch === 95 || - ch > 127 && isUnicodeIdentifierPart(ch, languageVersion); - } function scanNumber() { var start = pos; while (isDigit(text.charCodeAt(pos))) @@ -2431,12 +2433,12 @@ var ts; var start = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (isIdentifierPart(ch)) { + if (isIdentifierPart(ch, languageVersion)) { pos++; } else if (ch === 92) { ch = peekUnicodeEscape(); - if (!(ch >= 0 && isIdentifierPart(ch))) { + if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } result += text.substring(start, pos); @@ -2459,7 +2461,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 67; + return token = 69; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -2538,7 +2540,7 @@ var ts; } return pos += 2, token = 31; } - return pos++, token = 48; + return pos++, token = 49; case 34: case 39: tokenValue = scanString(); @@ -2547,42 +2549,48 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 60; + return pos += 2, token = 62; } - return pos++, token = 39; + return pos++, token = 40; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 50; + return pos += 2, token = 51; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; + return pos += 2, token = 66; } - return pos++, token = 45; + return pos++, token = 46; case 40: return pos++, token = 17; case 41: return pos++, token = 18; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; + return pos += 2, token = 59; + } + if (text.charCodeAt(pos + 1) === 42) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 60; + } + return pos += 2, token = 38; } return pos++, token = 37; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 40; + return pos += 2, token = 41; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 56; + return pos += 2, token = 57; } return pos++, token = 35; case 44: return pos++, token = 24; case 45: if (text.charCodeAt(pos + 1) === 45) { - return pos += 2, token = 41; + return pos += 2, token = 42; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; + return pos += 2, token = 58; } return pos++, token = 36; case 46: @@ -2637,9 +2645,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; + return pos += 2, token = 61; } - return pos++, token = 38; + return pos++, token = 39; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -2687,7 +2695,7 @@ var ts; tokenValue = "" + scanNumber(); return token = 8; case 58: - return pos++, token = 53; + return pos++, token = 54; case 59: return pos++, token = 23; case 60: @@ -2702,14 +2710,16 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 61; + return pos += 3, token = 63; } - return pos += 2, token = 42; + return pos += 2, token = 43; } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 28; } - if (text.charCodeAt(pos + 1) === 47 && languageVariant === 1) { + if (languageVariant === 1 && + text.charCodeAt(pos + 1) === 47 && + text.charCodeAt(pos + 2) !== 42) { return pos += 2, token = 26; } return pos++, token = 25; @@ -2732,7 +2742,7 @@ var ts; if (text.charCodeAt(pos + 1) === 62) { return pos += 2, token = 34; } - return pos++, token = 55; + return pos++, token = 56; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2745,35 +2755,35 @@ var ts; } return pos++, token = 27; case 63: - return pos++, token = 52; + return pos++, token = 53; case 91: return pos++, token = 19; case 93: return pos++, token = 20; case 94: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 66; + return pos += 2, token = 68; } - return pos++, token = 47; + return pos++, token = 48; case 123: return pos++, token = 15; case 124: if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 51; + return pos += 2, token = 52; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 65; + return pos += 2, token = 67; } - return pos++, token = 46; + return pos++, token = 47; case 125: return pos++, token = 16; case 126: - return pos++, token = 49; + return pos++, token = 50; case 64: - return pos++, token = 54; + return pos++, token = 55; case 92: var cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); @@ -2781,9 +2791,9 @@ var ts; error(ts.Diagnostics.Invalid_character); return pos++, token = 0; default: - if (isIdentifierStart(ch)) { + if (isIdentifierStart(ch, languageVersion)) { pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos))) + while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) pos++; tokenValue = text.substring(tokenPos, pos); if (ch === 92) { @@ -2810,14 +2820,14 @@ var ts; if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 63; + return pos += 3, token = 65; } - return pos += 2, token = 44; + return pos += 2, token = 45; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 64; } - return pos++, token = 43; + return pos++, token = 44; } if (text.charCodeAt(pos) === 61) { return pos++, token = 29; @@ -2826,7 +2836,7 @@ var ts; return token; } function reScanSlashToken() { - if (token === 38 || token === 59) { + if (token === 39 || token === 61) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -2860,7 +2870,7 @@ var ts; } p++; } - while (p < end && isIdentifierPart(text.charCodeAt(p))) { + while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { p++; } pos = p; @@ -2903,14 +2913,14 @@ var ts; break; } } - return token = 234; + return token = 236; } function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) { + if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { pos++; } else { @@ -2977,16 +2987,16 @@ var ts; (function (ts) { ts.bindTime = 0; function getModuleInstanceState(node) { - if (node.kind === 213 || node.kind === 214) { + if (node.kind === 215 || node.kind === 216) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 220 || node.kind === 219) && !(node.flags & 1)) { + else if ((node.kind === 222 || node.kind === 221) && !(node.flags & 1)) { return 0; } - else if (node.kind === 217) { + else if (node.kind === 219) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -3002,7 +3012,7 @@ var ts; }); return state; } - else if (node.kind === 216) { + else if (node.kind === 218) { return getModuleInstanceState(node.body); } else { @@ -3021,6 +3031,8 @@ var ts; var container; var blockScopeContainer; var lastContainer; + var seenThisKeyword; + var isJavaScriptFile = ts.isSourceFileJavaScript(file); var inStrictMode = !!file.externalModuleIndicator; var symbolCount = 0; var Symbol = ts.objectAllocator.getSymbolConstructor(); @@ -3054,10 +3066,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 216 && node.name.kind === 9) { + if (node.kind === 218 && node.name.kind === 9) { return "\"" + node.name.text + "\""; } - if (node.name.kind === 134) { + if (node.name.kind === 136) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -3065,22 +3077,24 @@ var ts; return node.name.text; } switch (node.kind) { - case 142: + case 144: return "__constructor"; - case 150: - case 145: + case 152: + case 147: return "__call"; - case 151: - case 146: + case 153: + case 148: return "__new"; - case 147: + case 149: return "__index"; - case 226: + case 228: return "__export"; - case 225: + case 227: return node.isExportEquals ? "export=" : "default"; - case 211: - case 212: + case 181: + return "export="; + case 213: + case 214: return node.flags & 1024 ? "default" : undefined; } } @@ -3089,7 +3103,8 @@ var ts; } function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); - var name = node.flags & 1024 && parent ? "default" : getDeclarationName(node); + var isDefaultExport = node.flags & 1024; + var name = isDefaultExport && parent ? "default" : getDeclarationName(node); var symbol; if (name !== undefined) { symbol = ts.hasProperty(symbolTable, name) @@ -3105,6 +3120,11 @@ var ts; var message = symbol.flags & 2 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; + ts.forEach(symbol.declarations, function (declaration) { + if (declaration.flags & 1024) { + message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + } + }); ts.forEach(symbol.declarations, function (declaration) { file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); }); @@ -3122,7 +3142,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 228 || (node.kind === 219 && hasExportModifier)) { + if (node.kind === 230 || (node.kind === 221 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -3161,44 +3181,51 @@ var ts; blockScopeContainer = node; blockScopeContainer.locals = undefined; } - ts.forEachChild(node, bind); + if (node.kind === 215) { + seenThisKeyword = false; + ts.forEachChild(node, bind); + node.flags = seenThisKeyword ? node.flags | 524288 : node.flags & ~524288; + } + else { + ts.forEachChild(node, bind); + } container = saveContainer; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } function getContainerFlags(node) { switch (node.kind) { - case 184: - case 212: - case 213: + case 186: + case 214: case 215: - case 153: - case 163: + case 217: + case 155: + case 165: return 1; - case 145: - case 146: case 147: - case 141: - case 140: - case 211: - case 142: + case 148: + case 149: case 143: + case 142: + case 213: case 144: - case 150: - case 151: - case 171: - case 172: + case 145: + case 146: + case 152: + case 153: + case 173: + case 174: + case 218: + case 248: case 216: - case 246: - case 214: return 5; - case 242: - case 197: - case 198: + case 244: case 199: - case 218: + case 200: + case 201: + case 220: return 2; - case 190: + case 192: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -3214,33 +3241,33 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 216: + case 218: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 246: + case 248: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 184: - case 212: + case 186: + case 214: return declareClassMember(node, symbolFlags, symbolExcludes); - case 215: + case 217: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 153: - case 163: - case 213: + case 155: + case 165: + case 215: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 150: - case 151: - case 145: - case 146: + case 152: + case 153: case 147: - case 141: - case 140: - case 142: + case 148: + case 149: case 143: + case 142: case 144: - case 211: - case 171: - case 172: - case 214: + case 145: + case 146: + case 213: + case 173: + case 174: + case 216: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -3264,11 +3291,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 246 ? node : node.body; - if (body.kind === 246 || body.kind === 217) { + var body = node.kind === 248 ? node : node.body; + if (body.kind === 248 || body.kind === 219) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 226 || stat.kind === 225) { + if (stat.kind === 228 || stat.kind === 227) { return true; } } @@ -3323,11 +3350,11 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 67) { + if (prop.name.kind !== 69) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 243 || prop.kind === 244 || prop.kind === 141 + var currentKind = prop.kind === 245 || prop.kind === 246 || prop.kind === 143 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -3349,10 +3376,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 216: + case 218: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 246: + case 248: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -3370,8 +3397,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 104 && - node.originalKeywordKind <= 112 && + node.originalKeywordKind >= 106 && + node.originalKeywordKind <= 114 && !ts.isIdentifierName(node)) { if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -3398,17 +3425,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 67) { + if (inStrictMode && node.expression.kind === 69) { var span = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 67 && + return node.kind === 69 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 67) { + if (name && name.kind === 69) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span = ts.getErrorSpanForNode(file, name); @@ -3442,7 +3469,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 40 || node.operator === 41) { + if (node.operator === 41 || node.operator === 42) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -3471,17 +3498,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 246: - case 217: + case 248: + case 219: updateStrictModeStatementList(node.statements); return; - case 190: + case 192: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 212: - case 184: + case 214: + case 186: inStrictMode = true; return; } @@ -3504,102 +3531,122 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 67: + case 69: return checkStrictModeIdentifier(node); - case 179: + case 181: + if (isJavaScriptFile) { + if (ts.isExportsPropertyAssignment(node)) { + bindExportsPropertyAssignment(node); + } + else if (ts.isModuleExportsAssignment(node)) { + bindModuleExportsAssignment(node); + } + } return checkStrictModeBinaryExpression(node); - case 242: + case 244: return checkStrictModeCatchClause(node); - case 173: + case 175: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 178: + case 180: return checkStrictModePostfixUnaryExpression(node); - case 177: + case 179: return checkStrictModePrefixUnaryExpression(node); - case 203: + case 205: return checkStrictModeWithStatement(node); - case 135: + case 97: + seenThisKeyword = true; + return; + case 137: return declareSymbolAndAddToSymbolTable(node, 262144, 530912); - case 136: + case 138: return bindParameter(node); - case 209: - case 161: + case 211: + case 163: return bindVariableDeclarationOrBindingElement(node); - case 139: - case 138: + case 141: + case 140: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); - case 243: - case 244: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); case 245: + case 246: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 247: return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 145: - case 146: case 147: + case 148: + case 149: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 141: - case 140: + case 143: + case 142: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 211: + case 213: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16, 106927); - case 142: + case 144: return declareSymbolAndAddToSymbolTable(node, 16384, 0); - case 143: + case 145: return bindPropertyOrMethodOrAccessor(node, 32768, 41919); - case 144: + case 146: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 150: - case 151: - return bindFunctionOrConstructorType(node); + case 152: case 153: + return bindFunctionOrConstructorType(node); + case 155: return bindAnonymousDeclaration(node, 2048, "__type"); - case 163: + case 165: return bindObjectLiteralExpression(node); - case 171: - case 172: + case 173: + case 174: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16, bindingName); - case 184: - case 212: + case 168: + if (isJavaScriptFile) { + bindCallExpression(node); + } + break; + case 186: + case 214: return bindClassLikeDeclaration(node); - case 213: + case 215: return bindBlockScopedDeclaration(node, 64, 792960); - case 214: + case 216: return bindBlockScopedDeclaration(node, 524288, 793056); - case 215: + case 217: return bindEnumDeclaration(node); - case 216: + case 218: return bindModuleDeclaration(node); - case 219: - case 222: + case 221: case 224: - case 228: + case 226: + case 230: return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 221: + case 223: return bindImportClause(node); - case 226: + case 228: return bindExportDeclaration(node); - case 225: + case 227: return bindExportAssignment(node); - case 246: + case 248: return bindSourceFileIfExternalModule(); } } function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); + bindSourceFileAsExternalModule(); } } + function bindSourceFileAsExternalModule() { + bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); + } function bindExportAssignment(node) { + var boundExpression = node.kind === 227 ? node.expression : node.right; if (!container.symbol || !container.symbol.exports) { bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } - else if (node.expression.kind === 67) { + else if (boundExpression.kind === 69) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } else { @@ -3619,8 +3666,27 @@ var ts; declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); } } + function setCommonJsModuleIndicator(node) { + if (!file.commonJsModuleIndicator) { + file.commonJsModuleIndicator = node; + bindSourceFileAsExternalModule(); + } + } + function bindExportsPropertyAssignment(node) { + setCommonJsModuleIndicator(node); + declareSymbol(file.symbol.exports, file.symbol, node.left, 4 | 7340032, 0); + } + function bindModuleExportsAssignment(node) { + setCommonJsModuleIndicator(node); + bindExportAssignment(node); + } + function bindCallExpression(node) { + if (!file.commonJsModuleIndicator && ts.isRequireCall(node)) { + setCommonJsModuleIndicator(node); + } + } function bindClassLikeDeclaration(node) { - if (node.kind === 212) { + if (node.kind === 214) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -3673,7 +3739,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 1, 107455); } if (node.flags & 112 && - node.parent.kind === 142 && + node.parent.kind === 144 && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); @@ -3719,7 +3785,8 @@ var ts; increaseIndent: function () { }, decreaseIndent: function () { }, clear: function () { return str = ""; }, - trackSymbol: function () { } + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } }; } return stringWriters.pop(); @@ -3781,7 +3848,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 246) { + while (node && node.kind !== 248) { node = node.parent; } return node; @@ -3872,15 +3939,15 @@ var ts; return current; } switch (current.kind) { - case 246: + case 248: + case 220: + case 244: case 218: - case 242: - case 216: - case 197: - case 198: case 199: + case 200: + case 201: return current; - case 190: + case 192: if (!isFunctionLike(current.parent)) { return current; } @@ -3891,9 +3958,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 209 && + declaration.kind === 211 && declaration.parent && - declaration.parent.kind === 242; + declaration.parent.kind === 244; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3929,22 +3996,22 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 246: + case 248: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 209: - case 161: - case 212: - case 184: - case 213: - case 216: - case 215: - case 245: case 211: - case 171: + case 163: + case 214: + case 186: + case 215: + case 218: + case 217: + case 247: + case 213: + case 173: errorNode = node.name; break; } @@ -3961,16 +4028,20 @@ var ts; return file.externalModuleIndicator !== undefined; } ts.isExternalModule = isExternalModule; + function isExternalOrCommonJsModule(file) { + return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; + } + ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isDeclarationFile(file) { return (file.flags & 8192) !== 0; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 215 && isConst(node); + return node.kind === 217 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 161 || isBindingPattern(node))) { + while (node && (node.kind === 163 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3978,14 +4049,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 209) { + if (node.kind === 211) { node = node.parent; } - if (node && node.kind === 210) { + if (node && node.kind === 212) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 191) { + if (node && node.kind === 193) { flags |= node.flags; } return flags; @@ -4000,7 +4071,7 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 193 && node.expression.kind === 9; + return node.kind === 195 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -4008,7 +4079,7 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - var commentRanges = (node.kind === 136 || node.kind === 135) ? + var commentRanges = (node.kind === 138 || node.kind === 137) ? ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : getLeadingCommentRangesOfNode(node, sourceFileOfNode); return ts.filter(commentRanges, isJsDocComment); @@ -4022,68 +4093,69 @@ var ts; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (149 <= node.kind && node.kind <= 158) { + if (151 <= node.kind && node.kind <= 160) { return true; } switch (node.kind) { - case 115: - case 126: + case 117: case 128: - case 118: - case 129: + case 130: + case 120: + case 131: return true; - case 101: - return node.parent.kind !== 175; + case 103: + return node.parent.kind !== 177; case 9: - return node.parent.kind === 136; - case 186: + return node.parent.kind === 138; + case 188: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 67: - if (node.parent.kind === 133 && node.parent.right === node) { + case 69: + if (node.parent.kind === 135 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 164 && node.parent.name === node) { + else if (node.parent.kind === 166 && node.parent.name === node) { node = node.parent; } - case 133: - case 164: - ts.Debug.assert(node.kind === 67 || node.kind === 133 || node.kind === 164, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 69 || node.kind === 135 || node.kind === 166, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 135: + case 166: + case 97: var parent_1 = node.parent; - if (parent_1.kind === 152) { + if (parent_1.kind === 154) { return false; } - if (149 <= parent_1.kind && parent_1.kind <= 158) { + if (151 <= parent_1.kind && parent_1.kind <= 160) { return true; } switch (parent_1.kind) { - case 186: + case 188: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 135: + case 137: return node === parent_1.constraint; - case 139: - case 138: - case 136: - case 209: - return node === parent_1.type; - case 211: - case 171: - case 172: - case 142: case 141: case 140: - case 143: - case 144: + case 138: + case 211: return node === parent_1.type; + case 213: + case 173: + case 174: + case 144: + case 143: + case 142: case 145: case 146: + return node === parent_1.type; case 147: + case 148: + case 149: return node === parent_1.type; - case 169: + case 171: return node === parent_1.type; - case 166: - case 167: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 168: + case 169: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 170: return false; } } @@ -4094,23 +4166,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 202: + case 204: return visitor(node); - case 218: - case 190: - case 194: - case 195: + case 220: + case 192: case 196: case 197: case 198: case 199: - case 203: - case 204: - case 239: - case 240: + case 200: + case 201: case 205: - case 207: + case 206: + case 241: case 242: + case 207: + case 209: + case 244: return ts.forEachChild(node, traverse); } } @@ -4120,23 +4192,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 182: + case 184: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } + case 217: case 215: - case 213: + case 218: case 216: case 214: - case 212: - case 184: + case 186: return; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 134) { + if (name_5 && name_5.kind === 136) { traverse(name_5.expression); return; } @@ -4151,14 +4223,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 161: - case 245: - case 136: - case 243: - case 139: + case 163: + case 247: case 138: - case 244: - case 209: + case 245: + case 141: + case 140: + case 246: + case 211: return true; } } @@ -4166,29 +4238,29 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 143 || node.kind === 144); + return node && (node.kind === 145 || node.kind === 146); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 212 || node.kind === 184); + return node && (node.kind === 214 || node.kind === 186); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 142: - case 171: - case 211: - case 172: - case 141: - case 140: - case 143: case 144: + case 173: + case 213: + case 174: + case 143: + case 142: case 145: case 146: case 147: - case 150: - case 151: + case 148: + case 149: + case 152: + case 153: return true; } } @@ -4197,24 +4269,24 @@ var ts; ts.isFunctionLike = isFunctionLike; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 141: - case 140: - case 142: case 143: + case 142: case 144: - case 211: - case 171: + case 145: + case 146: + case 213: + case 173: return true; } return false; } ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 190 && isFunctionLike(node.parent); + return node && node.kind === 192 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 141 && node.parent.kind === 163; + return node && node.kind === 143 && node.parent.kind === 165; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -4242,36 +4314,39 @@ var ts; return undefined; } switch (node.kind) { - case 134: + case 136: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 137: - if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { + case 139: + if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 172: + case 174: if (!includeArrowFunctions) { continue; } - case 211: - case 171: - case 216: - case 139: - case 138: + case 213: + case 173: + case 218: case 141: case 140: - case 142: case 143: + case 142: case 144: - case 215: - case 246: + case 145: + case 146: + case 147: + case 148: + case 149: + case 217: + case 248: return node; } } @@ -4283,33 +4358,33 @@ var ts; if (!node) return node; switch (node.kind) { - case 134: + case 136: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 137: - if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { + case 139: + if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 211: - case 171: - case 172: + case 213: + case 173: + case 174: if (!includeFunctions) { continue; } - case 139: - case 138: case 141: case 140: - case 142: case 143: + case 142: case 144: + case 145: + case 146: return node; } } @@ -4318,12 +4393,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 149: + case 151: return node.typeName; - case 186: + case 188: return node.expression; - case 67: - case 133: + case 69: + case 135: return node; } } @@ -4331,7 +4406,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 168) { + if (node.kind === 170) { return node.tag; } return node.expression; @@ -4339,40 +4414,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 212: + case 214: return true; - case 139: - return node.parent.kind === 212; - case 136: - return node.parent.body && node.parent.parent.kind === 212; - case 143: - case 144: case 141: - return node.body && node.parent.kind === 212; + return node.parent.kind === 214; + case 138: + return node.parent.body && node.parent.parent.kind === 214; + case 145: + case 146: + case 143: + return node.body && node.parent.kind === 214; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 212: + case 214: if (node.decorators) { return true; } return false; - case 139: - case 136: + case 141: + case 138: if (node.decorators) { return true; } return false; - case 143: + case 145: if (node.body && node.decorators) { return true; } return false; - case 141: - case 144: + case 143: + case 146: if (node.body && node.decorators) { return true; } @@ -4383,10 +4458,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 212: + case 214: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 141: - case 144: + case 143: + case 146: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -4396,95 +4471,105 @@ var ts; return nodeIsDecorated(node) || childIsDecorated(node); } ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; + function isPropertyAccessExpression(node) { + return node.kind === 166; + } + ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isElementAccessExpression(node) { + return node.kind === 167; + } + ts.isElementAccessExpression = isElementAccessExpression; function isExpression(node) { switch (node.kind) { case 95: case 93: - case 91: - case 97: - case 82: + case 99: + case 84: case 10: - case 162: - case 163: case 164: case 165: case 166: case 167: case 168: - case 187: case 169: case 170: + case 189: case 171: - case 184: case 172: - case 175: case 173: + case 186: case 174: case 177: - case 178: + case 175: + case 176: case 179: case 180: - case 183: case 181: - case 11: - case 185: - case 231: - case 232: case 182: + case 185: + case 183: + case 11: + case 187: + case 233: + case 234: + case 184: + case 178: return true; - case 133: - while (node.parent.kind === 133) { + case 135: + while (node.parent.kind === 135) { node = node.parent; } - return node.parent.kind === 152; - case 67: - if (node.parent.kind === 152) { + return node.parent.kind === 154; + case 69: + if (node.parent.kind === 154) { return true; } case 8: case 9: + case 97: var parent_2 = node.parent; switch (parent_2.kind) { - case 209: - case 136: - case 139: + case 211: case 138: + case 141: + case 140: + case 247: case 245: - case 243: - case 161: + case 163: return parent_2.initializer === node; - case 193: - case 194: case 195: case 196: - case 202: - case 203: + case 197: + case 198: case 204: - case 239: + case 205: + case 206: + case 241: + case 208: case 206: - case 204: return parent_2.expression === node; - case 197: + case 199: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 210) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 212) || forStatement.condition === node || forStatement.incrementor === node; - case 198: - case 199: + case 200: + case 201: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 212) || forInStatement.expression === node; - case 169: - case 187: + case 171: + case 189: return node === parent_2.expression; - case 188: + case 190: return node === parent_2.expression; - case 134: + case 136: return node === parent_2.expression; - case 137: - case 238: + case 139: + case 240: + case 239: return true; - case 186: + case 188: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -4495,6 +4580,10 @@ var ts; return false; } ts.isExpression = isExpression; + function isExternalModuleNameRelative(moduleName) { + return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); return moduleState === 1 || @@ -4502,7 +4591,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 219 && node.moduleReference.kind === 230; + return node.kind === 221 && node.moduleReference.kind === 232; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -4511,20 +4600,54 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 219 && node.moduleReference.kind !== 230; + return node.kind === 221 && node.moduleReference.kind !== 232; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; + function isSourceFileJavaScript(file) { + return isInJavaScriptFile(file); + } + ts.isSourceFileJavaScript = isSourceFileJavaScript; + function isInJavaScriptFile(node) { + return node && !!(node.parserContextFlags & 32); + } + ts.isInJavaScriptFile = isInJavaScriptFile; + function isRequireCall(expression) { + return expression.kind === 168 && + expression.expression.kind === 69 && + expression.expression.text === "require" && + expression.arguments.length === 1; + } + ts.isRequireCall = isRequireCall; + function isExportsPropertyAssignment(expression) { + return isInJavaScriptFile(expression) && + (expression.kind === 181) && + (expression.operatorToken.kind === 56) && + (expression.left.kind === 166) && + (expression.left.expression.kind === 69) && + ((expression.left.expression).text === "exports"); + } + ts.isExportsPropertyAssignment = isExportsPropertyAssignment; + function isModuleExportsAssignment(expression) { + return isInJavaScriptFile(expression) && + (expression.kind === 181) && + (expression.operatorToken.kind === 56) && + (expression.left.kind === 166) && + (expression.left.expression.kind === 69) && + ((expression.left.expression).text === "module") && + (expression.left.name.text === "exports"); + } + ts.isModuleExportsAssignment = isModuleExportsAssignment; function getExternalModuleName(node) { - if (node.kind === 220) { + if (node.kind === 222) { return node.moduleSpecifier; } - if (node.kind === 219) { + if (node.kind === 221) { var reference = node.moduleReference; - if (reference.kind === 230) { + if (reference.kind === 232) { return reference.expression; } } - if (node.kind === 226) { + if (node.kind === 228) { return node.moduleSpecifier; } } @@ -4532,13 +4655,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 136: + case 138: + case 143: + case 142: + case 246: + case 245: case 141: case 140: - case 244: - case 243: - case 139: - case 138: return node.questionToken !== undefined; } } @@ -4546,9 +4669,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 259 && + return node.kind === 261 && node.parameters.length > 0 && - node.parameters[0].type.kind === 261; + node.parameters[0].type.kind === 263; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -4562,24 +4685,24 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 267); + return getJSDocTag(node, 269); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 266); + return getJSDocTag(node, 268); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 268); + return getJSDocTag(node, 270); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 67) { + if (parameter.name && parameter.name.kind === 69) { var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 265) { + if (t.kind === 267) { var parameterTag = t; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { @@ -4598,12 +4721,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32) { - if (node.type && node.type.kind === 260) { + if (node.type && node.type.kind === 262) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 260; + return paramTag.typeExpression.type.kind === 262; } } return node.dotDotDotToken !== undefined; @@ -4624,7 +4747,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 160 || node.kind === 159); + return !!node && (node.kind === 162 || node.kind === 161); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -4639,34 +4762,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 172: - case 161: - case 212: - case 184: - case 142: + case 174: + case 163: + case 214: + case 186: + case 144: + case 217: + case 247: + case 230: + case 213: + case 173: + case 145: + case 223: + case 221: + case 226: case 215: - case 245: - case 228: - case 211: - case 171: case 143: - case 221: - case 219: + case 142: + case 218: case 224: - case 213: + case 138: + case 245: case 141: case 140: + case 146: + case 246: case 216: - case 222: - case 136: - case 243: - case 139: - case 138: - case 144: - case 244: - case 214: - case 135: - case 209: + case 137: + case 211: return true; } return false; @@ -4674,25 +4797,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 201: - case 200: - case 208: + case 203: + case 202: + case 210: + case 197: case 195: + case 194: + case 200: + case 201: + case 199: + case 196: + case 207: + case 204: + case 206: + case 98: + case 209: case 193: - case 192: case 198: - case 199: - case 197: - case 194: case 205: - case 202: - case 204: - case 96: - case 207: - case 191: - case 196: - case 203: - case 225: + case 227: return true; default: return false; @@ -4701,13 +4824,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 142: - case 139: + case 144: case 141: case 143: - case 144: - case 140: - case 147: + case 145: + case 146: + case 142: + case 149: return true; default: return false; @@ -4715,11 +4838,11 @@ var ts; } ts.isClassElement = isClassElement; function isDeclarationName(name) { - if (name.kind !== 67 && name.kind !== 9 && name.kind !== 8) { + if (name.kind !== 69 && name.kind !== 9 && name.kind !== 8) { return false; } var parent = name.parent; - if (parent.kind === 224 || parent.kind === 228) { + if (parent.kind === 226 || parent.kind === 230) { if (parent.propertyName) { return true; } @@ -4733,54 +4856,54 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 139: - case 138: case 141: case 140: case 143: - case 144: + case 142: + case 145: + case 146: + case 247: case 245: - case 243: - case 164: + case 166: return parent.name === node; - case 133: + case 135: if (parent.right === node) { - while (parent.kind === 133) { + while (parent.kind === 135) { parent = parent.parent; } - return parent.kind === 152; + return parent.kind === 154; } return false; - case 161: - case 224: + case 163: + case 226: return parent.propertyName === node; - case 228: + case 230: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 219 || - node.kind === 221 && !!node.name || - node.kind === 222 || + return node.kind === 221 || + node.kind === 223 && !!node.name || node.kind === 224 || - node.kind === 228 || - node.kind === 225 && node.expression.kind === 67; + node.kind === 226 || + node.kind === 230 || + node.kind === 227 && node.expression.kind === 69; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 81); + var heritageClause = getHeritageClause(node.heritageClauses, 83); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 104); + var heritageClause = getHeritageClause(node.heritageClauses, 106); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 81); + var heritageClause = getHeritageClause(node.heritageClauses, 83); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -4849,7 +4972,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 68 <= token && token <= 132; + return 70 <= token && token <= 134; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -4862,19 +4985,19 @@ var ts; ts.isAsyncFunctionLike = isAsyncFunctionLike; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 134 && + declaration.name.kind === 136 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 164 && isESSymbolIdentifier(node.expression); + return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 67 || name.kind === 9 || name.kind === 8) { + if (name.kind === 69 || name.kind === 9 || name.kind === 8) { return name.text; } - if (name.kind === 134) { + if (name.kind === 136) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4889,21 +5012,21 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 67 && node.text === "Symbol"; + return node.kind === 69 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 113: - case 116: - case 72: - case 120: - case 75: - case 80: + case 115: + case 118: + case 74: + case 122: + case 77: + case 82: + case 112: case 110: - case 108: - case 109: case 111: + case 113: return true; } return false; @@ -4911,28 +5034,28 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 136; + return root.kind === 138; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 161) { + while (node.kind === 163) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 216 || n.kind === 246; + return isFunctionLike(n) || n.kind === 218 || n.kind === 248; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function cloneEntityName(node) { - if (node.kind === 67) { - var clone_1 = createSynthesizedNode(67); + if (node.kind === 69) { + var clone_1 = createSynthesizedNode(69); clone_1.text = node.text; return clone_1; } else { - var clone_2 = createSynthesizedNode(133); + var clone_2 = createSynthesizedNode(135); clone_2.left = cloneEntityName(node.left); clone_2.left.parent = clone_2; clone_2.right = cloneEntityName(node.right); @@ -5175,7 +5298,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 142 && nodeIsPresent(member.body)) { + if (member.kind === 144 && nodeIsPresent(member.body)) { return member; } }); @@ -5202,10 +5325,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 143) { + if (accessor.kind === 145) { getAccessor = accessor; } - else if (accessor.kind === 144) { + else if (accessor.kind === 146) { setAccessor = accessor; } else { @@ -5214,7 +5337,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 143 || member.kind === 144) + if ((member.kind === 145 || member.kind === 146) && (member.flags & 128) === (accessor.flags & 128)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -5225,10 +5348,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 143 && !getAccessor) { + if (member.kind === 145 && !getAccessor) { getAccessor = member; } - if (member.kind === 144 && !setAccessor) { + if (member.kind === 146 && !setAccessor) { setAccessor = member; } } @@ -5334,16 +5457,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 111: return 128; - case 110: return 16; - case 109: return 64; - case 108: return 32; - case 113: return 256; - case 80: return 1; - case 120: return 2; - case 72: return 32768; - case 75: return 1024; - case 116: return 512; + case 113: return 128; + case 112: return 16; + case 111: return 64; + case 110: return 32; + case 115: return 256; + case 82: return 1; + case 122: return 2; + case 74: return 32768; + case 77: return 1024; + case 118: return 512; } return 0; } @@ -5351,29 +5474,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 164: - case 165: - case 167: case 166: - case 231: - case 232: + case 167: + case 169: case 168: - case 162: + case 233: + case 234: case 170: - case 163: - case 184: - case 171: - case 67: + case 164: + case 172: + case 165: + case 186: + case 173: + case 69: case 10: case 8: case 9: case 11: - case 181: - case 82: - case 91: - case 95: - case 97: + case 183: + case 84: case 93: + case 97: + case 99: + case 95: return true; } } @@ -5381,12 +5504,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 55 && token <= 66; + return token >= 56 && token <= 68; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 186 && - node.parent.token === 81 && + return node.kind === 188 && + node.parent.token === 83 && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -5395,10 +5518,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 67) { + if (node.kind === 69) { return true; } - else if (node.kind === 164) { + else if (isPropertyAccessExpression(node)) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -5406,16 +5529,16 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 133 && node.parent.right === node) || - (node.parent.kind === 164 && node.parent.name === node); + return (node.parent.kind === 135 && node.parent.right === node) || + (node.parent.kind === 166 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 163) { + if (kind === 165) { return expression.properties.length === 0; } - if (kind === 162) { + if (kind === 164) { return expression.elements.length === 0; } return false; @@ -5425,12 +5548,12 @@ var ts; return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function isJavaScript(fileName) { - return ts.fileExtensionIs(fileName, ".js"); + function hasJavaScriptFileExtension(fileName) { + return ts.fileExtensionIs(fileName, ".js") || ts.fileExtensionIs(fileName, ".jsx"); } - ts.isJavaScript = isJavaScript; + ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; function isTsx(fileName) { - return ts.fileExtensionIs(fileName, ".tsx"); + return ts.fileExtensionIs(fileName, ".tsx") || ts.fileExtensionIs(fileName, ".jsx"); } ts.isTsx = isTsx; function getExpandedCharCodes(input) { @@ -5624,9 +5747,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 135) { + if (d && d.kind === 137) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 215) { return current; } } @@ -5636,7 +5759,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var nodeConstructors = new Array(270); + var nodeConstructors = new Array(272); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -5674,20 +5797,26 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 133: + case 135: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 135: + case 137: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 136: - case 139: + case 246: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.equalsToken) || + visitNode(cbNode, node.objectAssignmentInitializer); case 138: - case 243: - case 244: - case 209: - case 161: + case 141: + case 140: + case 245: + case 211: + case 163: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -5696,24 +5825,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 150: - case 151: - case 145: - case 146: + case 152: + case 153: case 147: + case 148: + case 149: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 141: - case 140: - case 142: case 143: + case 142: case 144: - case 171: - case 211: - case 172: + case 145: + case 146: + case 173: + case 213: + case 174: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -5724,290 +5853,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 149: + case 151: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 148: + case 150: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 152: - return visitNode(cbNode, node.exprName); - case 153: - return visitNodes(cbNodes, node.members); case 154: - return visitNode(cbNode, node.elementType); + return visitNode(cbNode, node.exprName); case 155: - return visitNodes(cbNodes, node.elementTypes); + return visitNodes(cbNodes, node.members); case 156: + return visitNode(cbNode, node.elementType); case 157: - return visitNodes(cbNodes, node.types); + return visitNodes(cbNodes, node.elementTypes); case 158: - return visitNode(cbNode, node.type); case 159: + return visitNodes(cbNodes, node.types); case 160: - return visitNodes(cbNodes, node.elements); + return visitNode(cbNode, node.type); + case 161: case 162: return visitNodes(cbNodes, node.elements); - case 163: - return visitNodes(cbNodes, node.properties); case 164: + return visitNodes(cbNodes, node.elements); + case 165: + return visitNodes(cbNodes, node.properties); + case 166: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 165: + case 167: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 166: - case 167: + case 168: + case 169: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 168: + case 170: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 169: + case 171: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 170: - return visitNode(cbNode, node.expression); - case 173: - return visitNode(cbNode, node.expression); - case 174: + case 172: return visitNode(cbNode, node.expression); case 175: return visitNode(cbNode, node.expression); + case 176: + return visitNode(cbNode, node.expression); case 177: + return visitNode(cbNode, node.expression); + case 179: return visitNode(cbNode, node.operand); - case 182: + case 184: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 176: - return visitNode(cbNode, node.expression); case 178: + return visitNode(cbNode, node.expression); + case 180: return visitNode(cbNode, node.operand); - case 179: + case 181: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 187: + case 189: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 180: + case 182: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 183: + case 185: return visitNode(cbNode, node.expression); - case 190: - case 217: + case 192: + case 219: return visitNodes(cbNodes, node.statements); - case 246: + case 248: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 191: + case 193: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 210: + case 212: return visitNodes(cbNodes, node.declarations); - case 193: + case 195: return visitNode(cbNode, node.expression); - case 194: + case 196: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 195: + case 197: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 196: + case 198: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 197: + case 199: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 198: + case 200: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 199: + case 201: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 200: - case 201: - return visitNode(cbNode, node.label); case 202: - return visitNode(cbNode, node.expression); case 203: + return visitNode(cbNode, node.label); + case 204: + return visitNode(cbNode, node.expression); + case 205: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 204: + case 206: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 218: + case 220: return visitNodes(cbNodes, node.clauses); - case 239: + case 241: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 240: + case 242: return visitNodes(cbNodes, node.statements); - case 205: + case 207: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 206: + case 208: return visitNode(cbNode, node.expression); - case 207: + case 209: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 242: + case 244: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 137: + case 139: return visitNode(cbNode, node.expression); - case 212: - case 184: + case 214: + case 186: 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 213: + case 215: 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 214: + case 216: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 215: + case 217: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 245: + case 247: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 216: + case 218: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 219: + case 221: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 220: + case 222: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 221: + case 223: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 222: + case 224: return visitNode(cbNode, node.name); - case 223: - case 227: + case 225: + case 229: return visitNodes(cbNodes, node.elements); - case 226: + case 228: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 224: - case 228: + case 226: + case 230: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 225: + case 227: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 181: + case 183: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 188: + case 190: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 134: + case 136: return visitNode(cbNode, node.expression); - case 241: + case 243: return visitNodes(cbNodes, node.types); - case 186: + case 188: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 230: + case 232: return visitNode(cbNode, node.expression); - case 229: - return visitNodes(cbNodes, node.decorators); case 231: + return visitNodes(cbNodes, node.decorators); + case 233: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 232: - case 233: + case 234: + case 235: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 236: + case 238: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 237: + case 239: return visitNode(cbNode, node.expression); - case 238: + case 240: return visitNode(cbNode, node.expression); - case 235: + case 237: return visitNode(cbNode, node.tagName); - case 247: + case 249: return visitNode(cbNode, node.type); - case 251: + case 253: return visitNodes(cbNodes, node.types); - case 252: + case 254: return visitNodes(cbNodes, node.types); - case 250: + case 252: return visitNode(cbNode, node.elementType); - case 254: - return visitNode(cbNode, node.type); - case 253: + case 256: return visitNode(cbNode, node.type); case 255: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.type); case 257: + return visitNodes(cbNodes, node.members); + case 259: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 258: + case 260: return visitNode(cbNode, node.type); - case 259: + case 261: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 260: + case 262: return visitNode(cbNode, node.type); - case 261: + case 263: return visitNode(cbNode, node.type); - case 262: + case 264: return visitNode(cbNode, node.type); - case 256: + case 258: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 263: - return visitNodes(cbNodes, node.tags); case 265: + return visitNodes(cbNodes, node.tags); + case 267: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 266: + case 268: return visitNode(cbNode, node.typeExpression); - case 267: + case 269: return visitNode(cbNode, node.typeExpression); - case 268: + case 270: return visitNodes(cbNodes, node.typeParameters); } } @@ -6048,13 +6177,14 @@ var ts; var contextFlags; var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes) { - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); + var isJavaScriptFile = ts.hasJavaScriptFileExtension(fileName) || _sourceText.lastIndexOf("// @language=javascript", 0) === 0; + initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor); var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); clearState(); return result; } Parser.parseSourceFile = parseSourceFile; - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor) { + function initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor) { sourceText = _sourceText; syntaxCursor = _syntaxCursor; parseDiagnostics = []; @@ -6062,7 +6192,7 @@ var ts; identifiers = {}; identifierCount = 0; nodeCount = 0; - contextFlags = ts.isJavaScript(fileName) ? 32 : 0; + contextFlags = isJavaScriptFile ? 32 : 0; parseErrorBeforeNextFinishedNode = false; scanner.setText(sourceText); scanner.setOnError(scanError); @@ -6080,6 +6210,9 @@ var ts; } function parseSourceFileWorker(fileName, languageVersion, setParentNodes) { sourceFile = createSourceFile(fileName, languageVersion); + if (contextFlags & 32) { + sourceFile.parserContextFlags = 32; + } token = nextToken(); processReferenceComments(sourceFile); sourceFile.statements = parseList(0, parseStatement); @@ -6093,7 +6226,7 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } - if (ts.isJavaScript(fileName)) { + if (ts.isSourceFileJavaScript(sourceFile)) { addJSDocComments(); } return sourceFile; @@ -6103,9 +6236,9 @@ var ts; return; function visit(node) { switch (node.kind) { - case 191: - case 211: - case 136: + case 193: + case 213: + case 138: addJSDocComment(node); } forEachChild(node, visit); @@ -6139,7 +6272,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(246, 0); + var sourceFile = createNode(248, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -6298,16 +6431,16 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token === 67) { + if (token === 69) { return true; } - if (token === 112 && inYieldContext()) { + if (token === 114 && inYieldContext()) { return false; } - if (token === 117 && inAwaitContext()) { + if (token === 119 && inAwaitContext()) { return false; } - return token > 103; + return token > 105; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -6403,15 +6536,15 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(67); - if (token !== 67) { + var node = createNode(69); + if (token !== 69) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(67, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(69, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -6443,7 +6576,7 @@ var ts; return token === 9 || token === 8 || ts.tokenIsIdentifierOrKeyword(token); } function parseComputedPropertyName() { - var node = createNode(134); + var node = createNode(136); parseExpected(19); node.expression = allowInAnd(parseExpression); parseExpected(20); @@ -6453,20 +6586,27 @@ var ts; return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 72) { - return nextToken() === 79; + if (token === 74) { + return nextToken() === 81; } - if (token === 80) { + if (token === 82) { nextToken(); - if (token === 75) { + if (token === 77) { return lookAhead(nextTokenIsClassOrFunction); } return token !== 37 && token !== 15 && canFollowModifier(); } - if (token === 75) { + if (token === 77) { return nextTokenIsClassOrFunction(); } + if (token === 113) { + nextToken(); + return canFollowModifier(); + } nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return false; + } return canFollowModifier(); } function parseAnyContextualModifier() { @@ -6480,7 +6620,7 @@ var ts; } function nextTokenIsClassOrFunction() { nextToken(); - return token === 71 || token === 85; + return token === 73 || token === 87; } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -6493,7 +6633,7 @@ var ts; case 3: return !(token === 23 && inErrorRecovery) && isStartOfStatement(); case 2: - return token === 69 || token === 75; + return token === 71 || token === 77; case 4: return isStartOfTypeMember(); case 5: @@ -6549,7 +6689,7 @@ var ts; ts.Debug.assert(token === 15); if (nextToken() === 16) { var next = nextToken(); - return next === 24 || next === 15 || next === 81 || next === 104; + return next === 24 || next === 15 || next === 83 || next === 106; } return true; } @@ -6562,8 +6702,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 104 || - token === 81) { + if (token === 106 || + token === 83) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -6587,13 +6727,13 @@ var ts; case 21: return token === 16; case 3: - return token === 16 || token === 69 || token === 75; + return token === 16 || token === 71 || token === 77; case 7: - return token === 15 || token === 81 || token === 104; + return token === 15 || token === 83 || token === 106; case 8: return isVariableDeclaratorListTerminator(); case 17: - return token === 27 || token === 17 || token === 15 || token === 81 || token === 104; + return token === 27 || token === 17 || token === 15 || token === 83 || token === 106; case 11: return token === 18 || token === 23; case 15: @@ -6607,11 +6747,11 @@ var ts; case 20: return token === 15 || token === 16; case 13: - return token === 27 || token === 38; + return token === 27 || token === 39; case 14: return token === 25 && lookAhead(nextTokenIsSlash); case 22: - return token === 18 || token === 53 || token === 16; + return token === 18 || token === 54 || token === 16; case 23: return token === 27 || token === 16; case 25: @@ -6732,17 +6872,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 142: - case 147: - case 143: case 144: - case 139: - case 189: - return true; + case 149: + case 145: + case 146: case 141: + case 191: + return true; + case 143: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 67 && - methodDeclaration.name.originalKeywordKind === 119; + var nameIsConstructor = methodDeclaration.name.kind === 69 && + methodDeclaration.name.originalKeywordKind === 121; return !nameIsConstructor; } } @@ -6751,8 +6891,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 239: - case 240: + case 241: + case 242: return true; } } @@ -6761,65 +6901,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 211: - case 191: - case 190: - case 194: + case 213: case 193: + case 192: + case 196: + case 195: + case 208: + case 204: case 206: + case 203: case 202: - case 204: - case 201: case 200: - case 198: + case 201: case 199: - case 197: - case 196: - case 203: - case 192: - case 207: + case 198: case 205: - case 195: - case 208: - case 220: - case 219: - case 226: - case 225: - case 216: - case 212: - case 213: - case 215: + case 194: + case 209: + case 207: + case 197: + case 210: + case 222: + case 221: + case 228: + case 227: + case 218: case 214: + case 215: + case 217: + case 216: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 245; + return node.kind === 247; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 146: + case 148: + case 142: + case 149: case 140: case 147: - case 138: - case 145: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 209) { + if (node.kind !== 211) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 136) { + if (node.kind !== 138) { return false; } var parameter = node; @@ -6919,7 +7059,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(21)) { - var node = createNode(133, entity.pos); + var node = createNode(135, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -6930,13 +7070,13 @@ var ts; if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(67, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(69, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(181); + var template = createNode(183); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); var templateSpans = []; @@ -6949,7 +7089,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(188); + var span = createNode(190); span.expression = allowInAnd(parseExpression); var literal; if (token === 16) { @@ -6984,14 +7124,14 @@ var ts; } function parseTypeReferenceOrTypePredicate() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 67 && token === 122 && !scanner.hasPrecedingLineBreak()) { + if (typeName.kind === 69 && token === 124 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(148, typeName.pos); + var node_1 = createNode(150, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(149, typeName.pos); + var node = createNode(151, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 25) { node.typeArguments = parseBracketedList(18, parseType, 25, 27); @@ -6999,15 +7139,15 @@ var ts; return finishNode(node); } function parseTypeQuery() { - var node = createNode(152); - parseExpected(99); + var node = createNode(154); + parseExpected(101); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(135); + var node = createNode(137); node.name = parseIdentifier(); - if (parseOptional(81)) { + if (parseOptional(83)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -7023,7 +7163,7 @@ var ts; } } function parseParameterType() { - if (parseOptional(53)) { + if (parseOptional(54)) { return token === 9 ? parseLiteralNode(true) : parseType(); @@ -7031,7 +7171,7 @@ var ts; return undefined; } function isStartOfParameter() { - return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 54; + return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 55; } function setModifiers(node, modifiers) { if (modifiers) { @@ -7040,7 +7180,7 @@ var ts; } } function parseParameter() { - var node = createNode(136); + var node = createNode(138); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(22); @@ -7048,7 +7188,7 @@ var ts; if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { nextToken(); } - node.questionToken = parseOptionalToken(52); + node.questionToken = parseOptionalToken(53); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); return finishNode(node); @@ -7095,10 +7235,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 146) { - parseExpected(90); + if (kind === 148) { + parseExpected(92); } - fillSignature(53, false, false, false, node); + fillSignature(54, false, false, false, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -7125,17 +7265,17 @@ var ts; else { nextToken(); } - if (token === 53 || token === 24) { + if (token === 54 || token === 24) { return true; } - if (token !== 52) { + if (token !== 53) { return false; } nextToken(); - return token === 53 || token === 24 || token === 20; + return token === 54 || token === 24 || token === 20; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(147, fullStart); + var node = createNode(149, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(16, parseParameter, 19, 20); @@ -7146,17 +7286,17 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (token === 17 || token === 25) { - var method = createNode(140, fullStart); + var method = createNode(142, fullStart); method.name = name; method.questionToken = questionToken; - fillSignature(53, false, false, false, method); + fillSignature(54, false, false, false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(138, fullStart); + var property = createNode(140, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -7190,22 +7330,22 @@ var ts; nextToken(); return token === 17 || token === 25 || - token === 52 || token === 53 || + token === 54 || canParseSemicolon(); } function parseTypeMember() { switch (token) { case 17: case 25: - return parseSignatureMember(145); + return parseSignatureMember(147); case 19: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); - case 90: + case 92: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(146); + return parseSignatureMember(148); } case 9: case 8: @@ -7235,7 +7375,7 @@ var ts; return token === 17 || token === 25; } function parseTypeLiteral() { - var node = createNode(153); + var node = createNode(155); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -7251,12 +7391,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(155); + var node = createNode(157); node.elementTypes = parseBracketedList(19, parseType, 19, 20); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(158); + var node = createNode(160); parseExpected(17); node.type = parseType(); parseExpected(18); @@ -7264,8 +7404,8 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 151) { - parseExpected(90); + if (kind === 153) { + parseExpected(92); } fillSignature(34, false, false, false, node); return finishNode(node); @@ -7276,16 +7416,17 @@ var ts; } function parseNonArrayType() { switch (token) { - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: + case 120: + case 131: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 101: + case 103: + case 97: return parseTokenNode(); - case 99: + case 101: return parseTypeQuery(); case 15: return parseTypeLiteral(); @@ -7299,17 +7440,18 @@ var ts; } function isStartOfType() { switch (token) { - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: + case 120: + case 131: + case 103: + case 97: case 101: - case 99: case 15: case 19: case 25: - case 90: + case 92: return true; case 17: return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -7325,7 +7467,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { parseExpected(20); - var node = createNode(154, type.pos); + var node = createNode(156, type.pos); node.elementType = type; type = finishNode(node); } @@ -7347,10 +7489,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(157, parseArrayTypeOrHigher, 45); + return parseUnionOrIntersectionType(159, parseArrayTypeOrHigher, 46); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(156, parseIntersectionTypeOrHigher, 46); + return parseUnionOrIntersectionType(158, parseIntersectionTypeOrHigher, 47); } function isStartOfFunctionType() { if (token === 25) { @@ -7365,8 +7507,8 @@ var ts; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 53 || token === 24 || - token === 52 || token === 55 || + if (token === 54 || token === 24 || + token === 53 || token === 56 || isIdentifier() || ts.isModifier(token)) { return true; } @@ -7384,23 +7526,23 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(150); + return parseFunctionOrConstructorType(152); } - if (token === 90) { - return parseFunctionOrConstructorType(151); + if (token === 92) { + return parseFunctionOrConstructorType(153); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(53) ? parseType() : undefined; + return parseOptional(54) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token) { + case 97: case 95: case 93: - case 91: - case 97: - case 82: + case 99: + case 84: case 8: case 9: case 11: @@ -7408,12 +7550,12 @@ var ts; case 17: case 19: case 15: - case 85: - case 71: - case 90: - case 38: - case 59: - case 67: + case 87: + case 73: + case 92: + case 39: + case 61: + case 69: return true; default: return isIdentifier(); @@ -7426,16 +7568,16 @@ var ts; switch (token) { case 35: case 36: + case 50: case 49: - case 48: - case 76: - case 99: + case 78: case 101: - case 40: + case 103: case 41: + case 42: case 25: - case 117: - case 112: + case 119: + case 114: return true; default: if (isBinaryOperator()) { @@ -7446,9 +7588,9 @@ var ts; } function isStartOfExpressionStatement() { return token !== 15 && - token !== 85 && - token !== 71 && - token !== 54 && + token !== 87 && + token !== 73 && + token !== 55 && isStartOfExpression(); } function allowInAndParseExpression() { @@ -7470,12 +7612,12 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 55) { + if (token !== 56) { if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15) || !isStartOfExpression()) { return undefined; } } - parseExpected(55); + parseExpected(56); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -7487,7 +7629,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 67 && token === 34) { + if (expr.kind === 69 && token === 34) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -7496,7 +7638,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 112) { + if (token === 114) { if (inYieldContext()) { return true; } @@ -7509,7 +7651,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(182); + var node = createNode(184); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 37 || isStartOfExpression())) { @@ -7523,8 +7665,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(172, identifier.pos); - var parameter = createNode(136, identifier.pos); + var node = createNode(174, identifier.pos); + var parameter = createNode(138, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -7554,7 +7696,7 @@ var ts; return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { - if (token === 17 || token === 25 || token === 116) { + if (token === 17 || token === 25 || token === 118) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } if (token === 34) { @@ -7563,7 +7705,7 @@ var ts; return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 116) { + if (token === 118) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; @@ -7579,7 +7721,7 @@ var ts; var third = nextToken(); switch (third) { case 34: - case 53: + case 54: case 15: return 1; default: @@ -7595,7 +7737,7 @@ var ts; if (!isIdentifier()) { return 0; } - if (nextToken() === 53) { + if (nextToken() === 54) { return 1; } return 2; @@ -7608,10 +7750,10 @@ var ts; if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 81) { + if (third === 83) { var fourth = nextToken(); switch (fourth) { - case 55: + case 56: case 27: return false; default: @@ -7635,10 +7777,10 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(172); + var node = createNode(174); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512); - fillSignature(53, false, isAsync, !allowAmbiguity, node); + fillSignature(54, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } @@ -7652,8 +7794,8 @@ var ts; return parseFunctionBlock(false, isAsync, false); } if (token !== 23 && - token !== 85 && - token !== 71 && + token !== 87 && + token !== 73 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(false, isAsync, true); @@ -7663,15 +7805,15 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (!questionToken) { return leftOperand; } - var node = createNode(180, leftOperand.pos); + var node = createNode(182, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(53, false, ts.Diagnostics._0_expected, ts.tokenToString(53)); + node.colonToken = parseExpectedToken(54, false, ts.Diagnostics._0_expected, ts.tokenToString(54)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -7680,19 +7822,22 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 88 || t === 132; + return t === 90 || t === 134; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); var newPrecedence = getBinaryOperatorPrecedence(); - if (newPrecedence <= precedence) { + var consumeCurrentOperator = token === 38 ? + newPrecedence >= precedence : + newPrecedence > precedence; + if (!consumeCurrentOperator) { break; } - if (token === 88 && inDisallowInContext()) { + if (token === 90 && inDisallowInContext()) { break; } - if (token === 114) { + if (token === 116) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -7708,22 +7853,22 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 88) { + if (inDisallowInContext() && token === 90) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 51: + case 52: return 1; - case 50: + case 51: return 2; - case 46: - return 3; case 47: + return 3; + case 48: return 4; - case 45: + case 46: return 5; case 30: case 31: @@ -7734,64 +7879,66 @@ var ts; case 27: case 28: case 29: - case 89: - case 88: - case 114: + case 91: + case 90: + case 116: return 7; - case 42: case 43: case 44: + case 45: return 8; case 35: case 36: return 9; case 37: - case 38: case 39: + case 40: return 10; + case 38: + return 11; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(179, left.pos); + var node = createNode(181, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(187, left.pos); + var node = createNode(189, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(177); + var node = createNode(179); node.operator = token; nextToken(); - node.operand = parseUnaryExpressionOrHigher(); + node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(173); + var node = createNode(175); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(174); + var node = createNode(176); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(175); + var node = createNode(177); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token === 117) { + if (token === 119) { if (inAwaitContext()) { return true; } @@ -7800,45 +7947,87 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(176); + var node = createNode(178); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseUnaryExpressionOrHigher() { if (isAwaitExpression()) { return parseAwaitExpression(); } + if (isIncrementExpression()) { + var incrementExpression = parseIncrementExpression(); + return token === 38 ? + parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : + incrementExpression; + } + var unaryOperator = token; + var simpleUnaryExpression = parseSimpleUnaryExpression(); + if (token === 38) { + var diagnostic; + var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); + if (simpleUnaryExpression.kind === 171) { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); + } + else { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, ts.tokenToString(unaryOperator)); + } + } + return simpleUnaryExpression; + } + function parseSimpleUnaryExpression() { switch (token) { case 35: case 36: + case 50: case 49: - case 48: - case 40: - case 41: return parsePrefixUnaryExpression(); - case 76: + case 78: return parseDeleteExpression(); - case 99: - return parseTypeOfExpression(); case 101: + return parseTypeOfExpression(); + case 103: return parseVoidExpression(); + case 25: + return parseTypeAssertion(); + default: + return parseIncrementExpression(); + } + } + function isIncrementExpression() { + switch (token) { + case 35: + case 36: + case 50: + case 49: + case 78: + case 101: + case 103: + return false; case 25: if (sourceFile.languageVariant !== 1) { - return parseTypeAssertion(); - } - if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(true); + return false; } default: - return parsePostfixExpressionOrHigher(); + return true; } } - function parsePostfixExpressionOrHigher() { + function parseIncrementExpression() { + if (token === 41 || token === 42) { + var node = createNode(179); + node.operator = token; + nextToken(); + node.operand = parseLeftHandSideExpressionOrHigher(); + return finishNode(node); + } + else if (sourceFile.languageVariant === 1 && token === 25 && lookAhead(nextTokenIsIdentifierOrKeyword)) { + return parseJsxElementOrSelfClosingElement(true); + } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 40 || token === 41) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(178, expression.pos); + if ((token === 41 || token === 42) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(180, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -7847,7 +8036,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token === 93 + var expression = token === 95 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -7861,7 +8050,7 @@ var ts; if (token === 17 || token === 21 || token === 19) { return expression; } - var node = createNode(164, expression.pos); + var node = createNode(166, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -7869,26 +8058,26 @@ var ts; } function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); - if (opening.kind === 233) { - var node = createNode(231, opening.pos); + if (opening.kind === 235) { + var node = createNode(233, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 232); + ts.Debug.assert(opening.kind === 234); return opening; } } function parseJsxText() { - var node = createNode(234, scanner.getStartPos()); + var node = createNode(236, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 234: + case 236: return parseJsxText(); case 15: return parseJsxExpression(false); @@ -7924,11 +8113,11 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token === 27) { - node = createNode(233, fullStart); + node = createNode(235, fullStart); scanJsxText(); } else { - parseExpected(38); + parseExpected(39); if (inExpressionContext) { parseExpected(27); } @@ -7936,7 +8125,7 @@ var ts; parseExpected(27, undefined, false); scanJsxText(); } - node = createNode(232, fullStart); + node = createNode(234, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -7947,7 +8136,7 @@ var ts; var elementName = parseIdentifierName(); while (parseOptional(21)) { scanJsxIdentifier(); - var node = createNode(133, elementName.pos); + var node = createNode(135, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); @@ -7955,7 +8144,7 @@ var ts; return elementName; } function parseJsxExpression(inExpressionContext) { - var node = createNode(238); + var node = createNode(240); parseExpected(15); if (token !== 16) { node.expression = parseExpression(); @@ -7974,9 +8163,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(236); + var node = createNode(238); node.name = parseIdentifierName(); - if (parseOptional(55)) { + if (parseOptional(56)) { switch (token) { case 9: node.initializer = parseLiteralNode(); @@ -7989,7 +8178,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(237); + var node = createNode(239); parseExpected(15); parseExpected(22); node.expression = parseExpression(); @@ -7997,7 +8186,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(235); + var node = createNode(237); parseExpected(26); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -8010,18 +8199,18 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(169); + var node = createNode(171); parseExpected(25); node.type = parseType(); parseExpected(27); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { var dotToken = parseOptionalToken(21); if (dotToken) { - var propertyAccess = createNode(164, expression.pos); + var propertyAccess = createNode(166, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -8029,7 +8218,7 @@ var ts; continue; } if (!inDecoratorContext() && parseOptional(19)) { - var indexedAccess = createNode(165, expression.pos); + var indexedAccess = createNode(167, expression.pos); indexedAccess.expression = expression; if (token !== 20) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -8043,7 +8232,7 @@ var ts; continue; } if (token === 11 || token === 12) { - var tagExpression = createNode(168, expression.pos); + var tagExpression = createNode(170, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 11 ? parseLiteralNode() @@ -8062,7 +8251,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(166, expression.pos); + var callExpr = createNode(168, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -8070,7 +8259,7 @@ var ts; continue; } else if (token === 17) { - var callExpr = createNode(166, expression.pos); + var callExpr = createNode(168, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -8103,18 +8292,18 @@ var ts; case 21: case 18: case 20: - case 53: + case 54: case 23: - case 52: + case 53: case 30: case 32: case 31: case 33: - case 50: case 51: - case 47: - case 45: + case 52: + case 48: case 46: + case 47: case 16: case 1: return true; @@ -8130,11 +8319,11 @@ var ts; case 9: case 11: return parseLiteralNode(); + case 97: case 95: case 93: - case 91: - case 97: - case 82: + case 99: + case 84: return parseTokenNode(); case 17: return parseParenthesizedExpression(); @@ -8142,19 +8331,19 @@ var ts; return parseArrayLiteralExpression(); case 15: return parseObjectLiteralExpression(); - case 116: + case 118: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 71: + case 73: return parseClassExpression(); - case 85: + case 87: return parseFunctionExpression(); - case 90: + case 92: return parseNewExpression(); - case 38: - case 59: + case 39: + case 61: if (reScanSlashToken() === 10) { return parseLiteralNode(); } @@ -8165,28 +8354,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(170); + var node = createNode(172); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); return finishNode(node); } function parseSpreadElement() { - var node = createNode(183); + var node = createNode(185); parseExpected(22); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 22 ? parseSpreadElement() : - token === 24 ? createNode(185) : + token === 24 ? createNode(187) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(162); + var node = createNode(164); parseExpected(19); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048; @@ -8195,11 +8384,11 @@ var ts; return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(121)) { - return parseAccessorDeclaration(143, fullStart, decorators, modifiers); + if (parseContextualModifier(123)) { + return parseAccessorDeclaration(145, fullStart, decorators, modifiers); } - else if (parseContextualModifier(127)) { - return parseAccessorDeclaration(144, fullStart, decorators, modifiers); + else if (parseContextualModifier(129)) { + return parseAccessorDeclaration(146, fullStart, decorators, modifiers); } return undefined; } @@ -8215,27 +8404,33 @@ var ts; var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - if ((token === 24 || token === 16) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(244, fullStart); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 || token === 16 || token === 56); + if (isShorthandPropertyAssignment) { + var shorthandDeclaration = createNode(246, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; + var equalsToken = parseOptionalToken(56); + if (equalsToken) { + shorthandDeclaration.equalsToken = equalsToken; + shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); + } return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(243, fullStart); + var propertyAssignment = createNode(245, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(53); + parseExpected(54); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(163); + var node = createNode(165); parseExpected(15); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048; @@ -8249,9 +8444,9 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(171); + var node = createNode(173); setModifiers(node, parseModifiers()); - parseExpected(85); + parseExpected(87); node.asteriskToken = parseOptionalToken(37); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); @@ -8260,7 +8455,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(53, isGenerator, isAsync, false, node); + fillSignature(54, isGenerator, isAsync, false, node); node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -8271,8 +8466,8 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(167); - parseExpected(90); + var node = createNode(169); + parseExpected(92); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token === 17) { @@ -8281,7 +8476,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(190); + var node = createNode(192); if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1, parseStatement); parseExpected(16); @@ -8309,25 +8504,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(192); + var node = createNode(194); parseExpected(23); return finishNode(node); } function parseIfStatement() { - var node = createNode(194); - parseExpected(86); + var node = createNode(196); + parseExpected(88); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(78) ? parseStatement() : undefined; + node.elseStatement = parseOptional(80) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(195); - parseExpected(77); + var node = createNode(197); + parseExpected(79); node.statement = parseStatement(); - parseExpected(102); + parseExpected(104); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); @@ -8335,8 +8530,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(196); - parseExpected(102); + var node = createNode(198); + parseExpected(104); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); @@ -8345,11 +8540,11 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(84); + parseExpected(86); parseExpected(17); var initializer = undefined; if (token !== 23) { - if (token === 100 || token === 106 || token === 72) { + if (token === 102 || token === 108 || token === 74) { initializer = parseVariableDeclarationList(true); } else { @@ -8357,22 +8552,22 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(88)) { - var forInStatement = createNode(198, pos); + if (parseOptional(90)) { + var forInStatement = createNode(200, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(18); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(132)) { - var forOfStatement = createNode(199, pos); + else if (parseOptional(134)) { + var forOfStatement = createNode(201, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(18); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(197, pos); + var forStatement = createNode(199, pos); forStatement.initializer = initializer; parseExpected(23); if (token !== 23 && token !== 18) { @@ -8390,7 +8585,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 201 ? 68 : 73); + parseExpected(kind === 203 ? 70 : 75); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -8398,8 +8593,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(202); - parseExpected(92); + var node = createNode(204); + parseExpected(94); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -8407,8 +8602,8 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(203); - parseExpected(103); + var node = createNode(205); + parseExpected(105); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); @@ -8416,30 +8611,30 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(239); - parseExpected(69); + var node = createNode(241); + parseExpected(71); node.expression = allowInAnd(parseExpression); - parseExpected(53); + parseExpected(54); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(240); - parseExpected(75); - parseExpected(53); + var node = createNode(242); + parseExpected(77); + parseExpected(54); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 69 ? parseCaseClause() : parseDefaultClause(); + return token === 71 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(204); - parseExpected(94); + var node = createNode(206); + parseExpected(96); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); - var caseBlock = createNode(218, scanner.getStartPos()); + var caseBlock = createNode(220, scanner.getStartPos()); parseExpected(15); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(16); @@ -8447,26 +8642,26 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(206); - parseExpected(96); + var node = createNode(208); + parseExpected(98); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(207); - parseExpected(98); + var node = createNode(209); + parseExpected(100); node.tryBlock = parseBlock(false); - node.catchClause = token === 70 ? parseCatchClause() : undefined; - if (!node.catchClause || token === 83) { - parseExpected(83); + node.catchClause = token === 72 ? parseCatchClause() : undefined; + if (!node.catchClause || token === 85) { + parseExpected(85); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(242); - parseExpected(70); + var result = createNode(244); + parseExpected(72); if (parseExpected(17)) { result.variableDeclaration = parseVariableDeclaration(); } @@ -8475,22 +8670,22 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(208); - parseExpected(74); + var node = createNode(210); + parseExpected(76); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 67 && parseOptional(53)) { - var labeledStatement = createNode(205, fullStart); + if (expression.kind === 69 && parseOptional(54)) { + var labeledStatement = createNode(207, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(193, fullStart); + var expressionStatement = createNode(195, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -8502,7 +8697,7 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 85 && !scanner.hasPrecedingLineBreak(); + return token === 87 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -8511,41 +8706,41 @@ var ts; function isDeclaration() { while (true) { switch (token) { - case 100: - case 106: - case 72: - case 85: - case 71: - case 79: + case 102: + case 108: + case 74: + case 87: + case 73: + case 81: return true; - case 105: - case 130: + case 107: + case 132: return nextTokenIsIdentifierOnSameLine(); - case 123: - case 124: + case 125: + case 126: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 116: - case 120: + case 115: + case 118: + case 122: + case 110: + case 111: + case 112: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 87: + case 89: nextToken(); return token === 9 || token === 37 || token === 15 || ts.tokenIsIdentifierOrKeyword(token); - case 80: + case 82: nextToken(); - if (token === 55 || token === 37 || - token === 15 || token === 75) { + if (token === 56 || token === 37 || + token === 15 || token === 77) { return true; } continue; - case 110: - case 108: - case 109: - case 111: case 113: nextToken(); continue; @@ -8559,44 +8754,44 @@ var ts; } function isStartOfStatement() { switch (token) { - case 54: + case 55: case 23: case 15: - case 100: - case 106: - case 85: - case 71: - case 79: - case 86: - case 77: case 102: - case 84: + case 108: + case 87: case 73: - case 68: - case 92: - case 103: + case 81: + case 88: + case 79: + case 104: + case 86: + case 75: + case 70: case 94: + case 105: case 96: case 98: - case 74: - case 70: - case 83: - return true; + case 100: + case 76: case 72: - case 80: - case 87: + case 85: + return true; + case 74: + case 82: + case 89: return isStartOfDeclaration(); - case 116: - case 120: - case 105: - case 123: - case 124: - case 130: + case 118: + case 122: + case 107: + case 125: + case 126: + case 132: return true; + case 112: case 110: - case 108: - case 109: case 111: + case 113: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -8615,60 +8810,60 @@ var ts; return parseEmptyStatement(); case 15: return parseBlock(false); - case 100: + case 102: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 106: + case 108: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 85: + case 87: return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 71: + case 73: return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); - case 86: + case 88: return parseIfStatement(); - case 77: + case 79: return parseDoStatement(); - case 102: + case 104: return parseWhileStatement(); - case 84: + case 86: return parseForOrForInOrForOfStatement(); - case 73: - return parseBreakOrContinueStatement(200); - case 68: - return parseBreakOrContinueStatement(201); - case 92: + case 75: + return parseBreakOrContinueStatement(202); + case 70: + return parseBreakOrContinueStatement(203); + case 94: return parseReturnStatement(); - case 103: + case 105: return parseWithStatement(); - case 94: - return parseSwitchStatement(); case 96: - return parseThrowStatement(); + return parseSwitchStatement(); case 98: - case 70: - case 83: + return parseThrowStatement(); + case 100: + case 72: + case 85: return parseTryStatement(); - case 74: + case 76: return parseDebuggerStatement(); - case 54: + case 55: return parseDeclaration(); - case 116: - case 105: - case 130: - case 123: - case 124: - case 120: - case 72: - case 79: - case 80: - case 87: - case 108: - case 109: + case 118: + case 107: + case 132: + case 125: + case 126: + case 122: + case 74: + case 81: + case 82: + case 89: case 110: - case 113: case 111: + case 112: + case 115: + case 113: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -8681,33 +8876,33 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 100: - case 106: - case 72: + case 102: + case 108: + case 74: return parseVariableStatement(fullStart, decorators, modifiers); - case 85: + case 87: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 71: + case 73: return parseClassDeclaration(fullStart, decorators, modifiers); - case 105: + case 107: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 130: + case 132: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 79: + case 81: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 123: - case 124: + case 125: + case 126: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 87: + case 89: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 80: + case 82: nextToken(); - return token === 75 || token === 55 ? + return token === 77 || token === 56 ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { - var node = createMissingNode(229, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(231, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -8728,23 +8923,23 @@ var ts; } function parseArrayBindingElement() { if (token === 24) { - return createNode(185); + return createNode(187); } - var node = createNode(161); + var node = createNode(163); node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(161); + var node = createNode(163); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 53) { + if (tokenIsIdentifier && token !== 54) { node.name = propertyName; } else { - parseExpected(53); + parseExpected(54); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -8752,14 +8947,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(159); + var node = createNode(161); parseExpected(15); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(16); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(160); + var node = createNode(162); parseExpected(19); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(20); @@ -8778,7 +8973,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(209); + var node = createNode(211); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -8787,21 +8982,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(210); + var node = createNode(212); switch (token) { - case 100: + case 102: break; - case 106: + case 108: node.flags |= 16384; break; - case 72: + case 74: node.flags |= 32768; break; default: ts.Debug.fail(); } nextToken(); - if (token === 132 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 134 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -8816,7 +9011,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 18; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(191, fullStart); + var node = createNode(193, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -8824,29 +9019,29 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(211, fullStart); + var node = createNode(213, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(85); + parseExpected(87); node.asteriskToken = parseOptionalToken(37); node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); - fillSignature(53, isGenerator, isAsync, false, node); + fillSignature(54, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(142, pos); + var node = createNode(144, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(119); - fillSignature(53, false, false, false, node); + parseExpected(121); + fillSignature(54, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(141, fullStart); + var method = createNode(143, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -8854,12 +9049,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512); - fillSignature(53, isGenerator, isAsync, false, method); + fillSignature(54, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(139, fullStart); + var property = createNode(141, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -8874,7 +9069,7 @@ var ts; function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { var asteriskToken = parseOptionalToken(37); var name = parsePropertyName(); - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } @@ -8890,16 +9085,16 @@ var ts; node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(53, false, false, false, node); + fillSignature(54, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { + case 112: case 110: - case 108: - case 109: case 111: + case 113: return true; default: return false; @@ -8907,7 +9102,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 54) { + if (token === 55) { return true; } while (ts.isModifier(token)) { @@ -8928,15 +9123,15 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 127 || idToken === 121) { + if (!ts.isKeyword(idToken) || idToken === 129 || idToken === 123) { return true; } switch (token) { case 17: case 25: + case 54: + case 56: case 53: - case 55: - case 52: return true; default: return canParseSemicolon(); @@ -8948,14 +9143,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(54)) { + if (!parseOptional(55)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(137, decoratorStart); + var decorator = createNode(139, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -8989,7 +9184,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 116) { + if (token === 118) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -9004,7 +9199,7 @@ var ts; } function parseClassElement() { if (token === 23) { - var result = createNode(189); + var result = createNode(191); nextToken(); return finishNode(result); } @@ -9015,7 +9210,7 @@ var ts; if (accessor) { return accessor; } - if (token === 119) { + if (token === 121) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -9029,23 +9224,23 @@ var ts; return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_7 = createMissingNode(67, true, ts.Diagnostics.Declaration_expected); + var name_7 = createMissingNode(69, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 184); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 186); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 214); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(71); - node.name = parseOptionalIdentifier(); + parseExpected(73); + node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(true); if (parseExpected(15)) { @@ -9057,6 +9252,14 @@ var ts; } return finishNode(node); } + function parseNameOfClassDeclarationOrExpression() { + return isIdentifier() && !isImplementsClause() + ? parseIdentifier() + : undefined; + } + function isImplementsClause() { + return token === 106 && lookAhead(nextTokenIsIdentifierOrKeyword); + } function parseHeritageClauses(isClassHeritageClause) { if (isHeritageClause()) { return parseList(20, parseHeritageClause); @@ -9067,8 +9270,8 @@ var ts; return parseList(20, parseHeritageClause); } function parseHeritageClause() { - if (token === 81 || token === 104) { - var node = createNode(241); + if (token === 83 || token === 106) { + var node = createNode(243); node.token = token; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -9077,7 +9280,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(186); + var node = createNode(188); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 25) { node.typeArguments = parseBracketedList(18, parseType, 25, 27); @@ -9085,16 +9288,16 @@ var ts; return finishNode(node); } function isHeritageClause() { - return token === 81 || token === 104; + return token === 83 || token === 106; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213, fullStart); + var node = createNode(215, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(105); + parseExpected(107); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(false); @@ -9102,28 +9305,28 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214, fullStart); + var node = createNode(216, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(130); + parseExpected(132); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(55); + parseExpected(56); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(245, scanner.getStartPos()); + var node = createNode(247, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); + var node = createNode(217, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(79); + parseExpected(81); node.name = parseIdentifier(); if (parseExpected(15)) { node.members = parseDelimitedList(6, parseEnumMember); @@ -9135,7 +9338,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(217, scanner.getStartPos()); + var node = createNode(219, scanner.getStartPos()); if (parseExpected(15)) { node.statements = parseList(1, parseStatement); parseExpected(16); @@ -9146,7 +9349,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(216, fullStart); + var node = createNode(218, fullStart); var namespaceFlag = flags & 131072; node.decorators = decorators; setModifiers(node, modifiers); @@ -9158,7 +9361,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216, fullStart); + var node = createNode(218, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -9167,11 +9370,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(124)) { + if (parseOptional(126)) { flags |= 131072; } else { - parseExpected(123); + parseExpected(125); if (token === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -9179,58 +9382,58 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 125 && + return token === 127 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 17; } function nextTokenIsSlash() { - return nextToken() === 38; + return nextToken() === 39; } function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 24 || - token === 131; + token === 133; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(87); + parseExpected(89); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 24 && token !== 131) { - var importEqualsDeclaration = createNode(219, fullStart); + if (token !== 24 && token !== 133) { + var importEqualsDeclaration = createNode(221, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(55); + parseExpected(56); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(220, fullStart); + var importDeclaration = createNode(222, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || token === 37 || token === 15) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(131); + parseExpected(133); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(221, fullStart); + var importClause = createNode(223, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(24)) { - importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(223); + importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(225); } return finishNode(importClause); } @@ -9240,8 +9443,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(230); - parseExpected(125); + var node = createNode(232); + parseExpected(127); parseExpected(17); node.expression = parseModuleSpecifier(); parseExpected(18); @@ -9255,22 +9458,22 @@ var ts; return result; } function parseNamespaceImport() { - var namespaceImport = createNode(222); + var namespaceImport = createNode(224); parseExpected(37); - parseExpected(114); + parseExpected(116); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 223 ? parseImportSpecifier : parseExportSpecifier, 15, 16); + node.elements = parseBracketedList(21, kind === 225 ? parseImportSpecifier : parseExportSpecifier, 15, 16); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(228); + return parseImportOrExportSpecifier(230); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(224); + return parseImportOrExportSpecifier(226); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -9278,9 +9481,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 114) { + if (token === 116) { node.propertyName = identifierName; - parseExpected(114); + parseExpected(116); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -9289,23 +9492,23 @@ var ts; else { node.name = identifierName; } - if (kind === 224 && checkIdentifierIsKeyword) { + if (kind === 226 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226, fullStart); + var node = createNode(228, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(37)) { - parseExpected(131); + parseExpected(133); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(227); - if (token === 131 || (token === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(131); + node.exportClause = parseNamedImportsOrExports(229); + if (token === 133 || (token === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(133); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -9313,14 +9516,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(227, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(55)) { + if (parseOptional(56)) { node.isExportEquals = true; } else { - parseExpected(75); + parseExpected(77); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -9383,10 +9586,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 219 && node.moduleReference.kind === 230 - || node.kind === 220 - || node.kind === 225 - || node.kind === 226 + || node.kind === 221 && node.moduleReference.kind === 232 + || node.kind === 222 + || node.kind === 227 + || node.kind === 228 ? node : undefined; }); @@ -9396,22 +9599,22 @@ var ts; function isJSDocType() { switch (token) { case 37: - case 52: + case 53: case 17: case 19: - case 48: + case 49: case 15: - case 85: + case 87: case 22: - case 90: - case 95: + case 92: + case 97: return true; } return ts.tokenIsIdentifierOrKeyword(token); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2, undefined); + initializeState("file.js", content, 2, true, undefined); var jsDocTypeExpression = parseJSDocTypeExpression(start, length); var diagnostics = parseDiagnostics; clearState(); @@ -9421,7 +9624,7 @@ var ts; function parseJSDocTypeExpression(start, length) { scanner.setText(sourceText, start, length); token = nextToken(); - var result = createNode(247); + var result = createNode(249); parseExpected(15); result.type = parseJSDocTopLevelType(); parseExpected(16); @@ -9431,13 +9634,13 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 46) { - var unionType = createNode(251, type.pos); + if (token === 47) { + var unionType = createNode(253, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 55) { - var optionalType = createNode(258, type.pos); + if (token === 56) { + var optionalType = createNode(260, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -9448,20 +9651,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 19) { - var arrayType = createNode(250, type.pos); + var arrayType = createNode(252, type.pos); arrayType.elementType = type; nextToken(); parseExpected(20); type = finishNode(arrayType); } - else if (token === 52) { - var nullableType = createNode(253, type.pos); + else if (token === 53) { + var nullableType = createNode(255, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 48) { - var nonNullableType = createNode(254, type.pos); + else if (token === 49) { + var nonNullableType = createNode(256, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -9476,80 +9679,80 @@ var ts; switch (token) { case 37: return parseJSDocAllType(); - case 52: + case 53: return parseJSDocUnknownOrNullableType(); case 17: return parseJSDocUnionType(); case 19: return parseJSDocTupleType(); - case 48: + case 49: return parseJSDocNonNullableType(); case 15: return parseJSDocRecordType(); - case 85: + case 87: return parseJSDocFunctionType(); case 22: return parseJSDocVariadicType(); - case 90: + case 92: return parseJSDocConstructorType(); - case 95: + case 97: return parseJSDocThisType(); - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: - case 101: + case 120: + case 131: + case 103: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(262); + var result = createNode(264); nextToken(); - parseExpected(53); + parseExpected(54); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(261); + var result = createNode(263); nextToken(); - parseExpected(53); + parseExpected(54); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(260); + var result = createNode(262); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(259); + var result = createNode(261); nextToken(); parseExpected(17); result.parameters = parseDelimitedList(22, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(18); - if (token === 53) { + if (token === 54) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(136); + var parameter = createNode(138); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(258, type.pos); + var result = createNode(260, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(257); + var result = createNode(259); result.name = parseSimplePropertyName(); while (parseOptional(21)) { if (token === 25) { @@ -9578,13 +9781,13 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(133, left.pos); + var result = createNode(135, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(255); + var result = createNode(257); nextToken(); result.members = parseDelimitedList(24, parseJSDocRecordMember); checkForTrailingComma(result.members); @@ -9592,22 +9795,22 @@ var ts; return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(256); + var result = createNode(258); result.name = parseSimplePropertyName(); - if (token === 53) { + if (token === 54) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(254); + var result = createNode(256); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(252); + var result = createNode(254); nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); @@ -9621,7 +9824,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(251); + var result = createNode(253); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(18); @@ -9632,14 +9835,14 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(46)) { + while (parseOptional(47)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(248); + var result = createNode(250); nextToken(); return finishNode(result); } @@ -9650,19 +9853,19 @@ var ts; token === 16 || token === 18 || token === 27 || - token === 55 || - token === 46) { - var result = createNode(249, pos); + token === 56 || + token === 47) { + var result = createNode(251, pos); return finishNode(result); } else { - var result = createNode(253, pos); + var result = createNode(255, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2, undefined); + initializeState("file.js", content, 2, true, undefined); var jsDocComment = parseJSDocComment(undefined, start, length); var diagnostics = parseDiagnostics; clearState(); @@ -9727,7 +9930,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(263, start); + var result = createNode(265, start); result.tags = tags; return finishNode(result, end); } @@ -9738,7 +9941,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64); - var atToken = createNode(54, pos - 1); + var atToken = createNode(55, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -9764,7 +9967,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(264, atToken.pos); + var result = createNode(266, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -9815,7 +10018,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(265, atToken.pos); + var result = createNode(267, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -9825,27 +10028,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 266; })) { + if (ts.forEach(tags, function (t) { return t.kind === 268; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(266, atToken.pos); + var result = createNode(268, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 267; })) { + if (ts.forEach(tags, function (t) { return t.kind === 269; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(267, atToken.pos); + var result = createNode(269, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 268; })) { + if (ts.forEach(tags, function (t) { return t.kind === 270; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -9858,7 +10061,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(135, name_8.pos); + var typeParameter = createNode(137, name_8.pos); typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -9869,7 +10072,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(268, atToken.pos); + var result = createNode(270, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -9890,7 +10093,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(67, startPos); + var result = createNode(69, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -9966,7 +10169,7 @@ var ts; switch (node.kind) { case 9: case 8: - case 67: + case 69: return true; } return false; @@ -10205,17 +10408,19 @@ var ts; var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); var typeCount = 0; + var symbolCount = 0; var emptyArray = []; var emptySymbols = {}; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; var emitResolver = createResolver(); var undefinedSymbol = createSymbol(4 | 67108864, "undefined"); var argumentsSymbol = createSymbol(4 | 67108864, "arguments"); var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, - getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount"); }, + getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, getTypeCount: function () { return typeCount; }, isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, @@ -10301,6 +10506,7 @@ var ts; var getInstantiatedGlobalPromiseLikeType; var getGlobalPromiseConstructorLikeType; var getGlobalThenableType; + var cjsRequireType; var tupleTypes = {}; var unionTypes = {}; var intersectionTypes = {}; @@ -10361,6 +10567,7 @@ var ts; diagnostics.add(diagnostic); } function createSymbol(flags, name) { + symbolCount++; return new Symbol(flags, name); } function getExcludedSymbolFlags(flags) { @@ -10489,10 +10696,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 246); + return ts.getAncestor(node, 248); } function isGlobalSourceFile(node) { - return node.kind === 246 && !ts.isExternalModule(node); + return node.kind === 248 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -10509,17 +10716,54 @@ var ts; } } } - function isDefinedBefore(node1, node2) { - var file1 = ts.getSourceFileOfNode(node1); - var file2 = ts.getSourceFileOfNode(node2); - if (file1 === file2) { - return node1.pos <= node2.pos; + function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { + var declarationFile = ts.getSourceFileOfNode(declaration); + var useFile = ts.getSourceFileOfNode(usage); + if (declarationFile !== useFile) { + if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) { + return true; + } + var sourceFiles = host.getSourceFiles(); + return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } - if (!compilerOptions.outFile && !compilerOptions.out) { - return true; + if (declaration.pos <= usage.pos) { + return declaration.kind !== 211 || + !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return isUsedInFunctionOrNonStaticProperty(declaration, usage); + function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + if (declaration.parent.parent.kind === 193 || + declaration.parent.parent.kind === 199) { + return isSameScopeDescendentOf(usage, declaration, container); + } + else if (declaration.parent.parent.kind === 201 || + declaration.parent.parent.kind === 200) { + var expression = declaration.parent.parent.expression; + return isSameScopeDescendentOf(usage, expression, container); + } + } + function isUsedInFunctionOrNonStaticProperty(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + var current = usage; + while (current) { + if (current === container) { + return false; + } + if (ts.isFunctionLike(current)) { + return true; + } + var initializerOfNonStaticProperty = current.parent && + current.parent.kind === 141 && + (current.parent.flags & 128) === 0 && + current.parent.initializer === current; + if (initializerOfNonStaticProperty) { + return true; + } + current = current.parent; + } + return false; } - var sourceFiles = host.getSourceFiles(); - return sourceFiles.indexOf(file1) <= sourceFiles.indexOf(file2); } function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { var result; @@ -10540,16 +10784,16 @@ var ts; } } switch (location.kind) { - case 246: - if (!ts.isExternalModule(location)) + case 248: + if (!ts.isExternalOrCommonJsModule(location)) break; - case 216: + case 218: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 246 || - (location.kind === 216 && location.name.kind === 9)) { + if (location.kind === 248 || + (location.kind === 218 && location.name.kind === 9)) { if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 228)) { + ts.getDeclarationOfKind(moduleExports[name], 230)) { break; } result = moduleExports["default"]; @@ -10563,13 +10807,13 @@ var ts; break loop; } break; - case 215: + case 217: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; - case 139: - case 138: + case 141: + case 140: if (ts.isClassLike(location.parent) && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -10579,9 +10823,9 @@ var ts; } } break; - case 212: - case 184: - case 213: + case 214: + case 186: + case 215: 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); @@ -10589,7 +10833,7 @@ var ts; } break loop; } - if (location.kind === 184 && meaning & 32) { + if (location.kind === 186 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -10597,28 +10841,28 @@ var ts; } } break; - case 134: + case 136: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 213) { + if (ts.isClassLike(grandparent) || grandparent.kind === 215) { 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 141: - case 140: - case 142: case 143: + case 142: case 144: - case 211: - case 172: + case 145: + case 146: + case 213: + case 174: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 171: + case 173: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -10631,8 +10875,8 @@ var ts; } } break; - case 137: - if (location.parent && location.parent.kind === 136) { + case 139: + if (location.parent && location.parent.kind === 138) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -10658,8 +10902,11 @@ var ts; error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); return undefined; } - if (meaning & 2 && result.flags & 2) { - checkResolvedBlockScopedVariable(result, errorLocation); + if (meaning & 2) { + var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); + if (exportOrLocalSymbol.flags & 2) { + checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); + } } } return result; @@ -10668,21 +10915,7 @@ var ts; ts.Debug.assert((result.flags & 2) !== 0); var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); - if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 209); - var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 191 || - variableDeclaration.parent.parent.kind === 197) { - isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); - } - else if (variableDeclaration.parent.parent.kind === 199 || - variableDeclaration.parent.parent.kind === 198) { - var expression = variableDeclaration.parent.parent.expression; - isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); - } - } - if (isUsedBeforeDeclaration) { + if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 211), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -10699,10 +10932,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 219) { + if (node.kind === 221) { return node; } - while (node && node.kind !== 220) { + while (node && node.kind !== 222) { node = node.parent; } return node; @@ -10712,7 +10945,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 230) { + if (node.moduleReference.kind === 232) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -10801,17 +11034,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 219: - return getTargetOfImportEqualsDeclaration(node); case 221: + return getTargetOfImportEqualsDeclaration(node); + case 223: return getTargetOfImportClause(node); - case 222: - return getTargetOfNamespaceImport(node); case 224: + return getTargetOfNamespaceImport(node); + case 226: return getTargetOfImportSpecifier(node); - case 228: + case 230: return getTargetOfExportSpecifier(node); - case 225: + case 227: return getTargetOfExportAssignment(node); } } @@ -10853,10 +11086,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 225) { + if (node.kind === 227) { checkExpressionCached(node.expression); } - else if (node.kind === 228) { + else if (node.kind === 230) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -10866,17 +11099,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 219); + importDeclaration = ts.getAncestor(entityName, 221); ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 67 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 69 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 67 || entityName.parent.kind === 133) { + if (entityName.kind === 69 || entityName.parent.kind === 135) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 219); + ts.Debug.assert(entityName.parent.kind === 221); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -10888,16 +11121,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 67) { + if (name.kind === 69) { var message = meaning === 1536 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 133 || name.kind === 164) { - var left = name.kind === 133 ? name.left : name.expression; - var right = name.kind === 133 ? name.right : name.name; + else if (name.kind === 135 || name.kind === 166) { + var left = name.kind === 135 ? name.left : name.expression; + var right = name.kind === 135 ? name.right : name.name; var namespace = resolveEntityName(left, 1536, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -10916,9 +11149,6 @@ var ts; ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); return symbol.flags & meaning ? symbol : resolveAlias(symbol); } - function isExternalModuleNameRelative(moduleName) { - return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; - } function resolveExternalModuleName(location, moduleReferenceExpression) { if (moduleReferenceExpression.kind !== 9) { return; @@ -10929,7 +11159,10 @@ var ts; if (moduleName === undefined) { return; } - var isRelative = isExternalModuleNameRelative(moduleName); + if (moduleName.indexOf("!") >= 0) { + moduleName = moduleName.substr(0, moduleName.indexOf("!")); + } + var isRelative = ts.isExternalModuleNameRelative(moduleName); if (!isRelative) { var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); if (symbol) { @@ -11033,7 +11266,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 142 && ts.nodeIsPresent(member.body)) { + if (member.kind === 144 && ts.nodeIsPresent(member.body)) { return member; } } @@ -11098,17 +11331,17 @@ var ts; } } switch (location_1.kind) { - case 246: - if (!ts.isExternalModule(location_1)) { + case 248: + if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 216: + case 218: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 212: - case 213: + case 214: + case 215: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -11141,7 +11374,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -11170,7 +11403,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -11225,8 +11458,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 216 && declaration.name.kind === 9) || - (declaration.kind === 246 && ts.isExternalModule(declaration)); + return (declaration.kind === 218 && declaration.name.kind === 9) || + (declaration.kind === 248 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -11258,11 +11491,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 152) { + if (entityName.parent.kind === 154) { meaning = 107455 | 1048576; } - else if (entityName.kind === 133 || entityName.kind === 164 || - entityName.parent.kind === 219) { + else if (entityName.kind === 135 || entityName.kind === 166 || + entityName.parent.kind === 221) { meaning = 1536; } else { @@ -11313,10 +11546,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 158) { + while (node.kind === 160) { node = node.parent; } - if (node.kind === 214) { + if (node.kind === 216) { return getSymbolOfNode(node); } } @@ -11330,10 +11563,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 184: + case 186: return "(Anonymous class)"; - case 171: - case 172: + case 173: + case 174: return "(Anonymous function)"; } } @@ -11394,6 +11627,7 @@ var ts; } function buildTypeDisplay(type, writer, enclosingDeclaration, globalFlags, symbolStack) { var globalFlagsToPass = globalFlags & 16; + var inObjectTypeLiteral = false; return writeType(type, globalFlags); function writeType(type, flags) { if (type.flags & 16777343) { @@ -11401,6 +11635,12 @@ var ts; ? "any" : type.intrinsicName); } + else if (type.flags & 33554432) { + if (inObjectTypeLiteral) { + writer.reportInaccessibleThisError(); + } + writer.writeKeyword("this"); + } else if (type.flags & 4096) { writeTypeReference(type, flags); } @@ -11439,9 +11679,9 @@ var ts; writeType(types[i], delimiter === 24 ? 0 : 64); } } - function writeSymbolTypeReference(symbol, typeArguments, pos, end) { - if (!isReservedMemberName(symbol.name)) { - buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056); + function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { + if (symbol.flags & 32 || !isReservedMemberName(symbol.name)) { + buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056, 0, flags); } if (pos < end) { writePunctuation(writer, 25); @@ -11455,7 +11695,7 @@ var ts; } } function writeTypeReference(type, flags) { - var typeArguments = type.typeArguments; + var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1)) { writeType(typeArguments[0], 64); writePunctuation(writer, 19); @@ -11473,12 +11713,13 @@ var ts; i++; } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_3, typeArguments, start, i); + writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); writePunctuation(writer, 21); } } } - writeSymbolTypeReference(type.symbol, typeArguments, i, typeArguments.length); + var typeParameterCount = (type.target.typeParameters || emptyArray).length; + writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags); } } function writeTupleType(type) { @@ -11490,7 +11731,7 @@ var ts; if (flags & 64) { writePunctuation(writer, 17); } - writeTypeList(type.types, type.flags & 16384 ? 46 : 45); + writeTypeList(type.types, type.flags & 16384 ? 47 : 46); if (flags & 64) { writePunctuation(writer, 18); } @@ -11510,7 +11751,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); } else { - writeKeyword(writer, 115); + writeKeyword(writer, 117); } } else { @@ -11531,7 +11772,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 246 || declaration.parent.kind === 217; + return declaration.parent.kind === 248 || declaration.parent.kind === 219; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -11540,7 +11781,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 99); + writeKeyword(writer, 101); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } @@ -11574,7 +11815,7 @@ var ts; if (flags & 64) { writePunctuation(writer, 17); } - writeKeyword(writer, 90); + writeKeyword(writer, 92); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); if (flags & 64) { @@ -11583,6 +11824,8 @@ var ts; return; } } + var saveInObjectTypeLiteral = inObjectTypeLiteral; + inObjectTypeLiteral = true; writePunctuation(writer, 15); writer.writeLine(); writer.increaseIndent(); @@ -11594,7 +11837,7 @@ var ts; } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 90); + writeKeyword(writer, 92); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 23); @@ -11603,11 +11846,11 @@ var ts; if (resolved.stringIndexType) { writePunctuation(writer, 19); writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); - writeKeyword(writer, 128); + writeKeyword(writer, 130); writePunctuation(writer, 20); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); writeType(resolved.stringIndexType, 0); writePunctuation(writer, 23); @@ -11616,11 +11859,11 @@ var ts; if (resolved.numberIndexType) { writePunctuation(writer, 19); writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); - writeKeyword(writer, 126); + writeKeyword(writer, 128); writePunctuation(writer, 20); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); writeType(resolved.numberIndexType, 0); writePunctuation(writer, 23); @@ -11635,7 +11878,7 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 23); @@ -11645,9 +11888,9 @@ var ts; else { buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); writeType(t, 0); writePunctuation(writer, 23); @@ -11656,6 +11899,7 @@ var ts; } writer.decreaseIndent(); writePunctuation(writer, 16); + inObjectTypeLiteral = saveInObjectTypeLiteral; } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { @@ -11669,7 +11913,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 81); + writeKeyword(writer, 83); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -11681,9 +11925,9 @@ var ts; } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } @@ -11730,14 +11974,14 @@ var ts; writePunctuation(writer, 34); } else { - writePunctuation(writer, 53); + writePunctuation(writer, 54); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 122); + writeKeyword(writer, 124); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -11771,13 +12015,13 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 216) { + if (node.kind === 218) { if (node.name.kind === 9) { return node; } } - else if (node.kind === 246) { - return ts.isExternalModule(node) ? node : undefined; + else if (node.kind === 248) { + return ts.isExternalOrCommonJsModule(node) ? node : undefined; } } ts.Debug.fail("getContainingModule cant reach here"); @@ -11819,59 +12063,59 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 161: + case 163: return isDeclarationVisible(node.parent.parent); - case 209: + case 211: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 216: - case 212: - case 213: + case 218: case 214: - case 211: case 215: - case 219: + case 216: + case 213: + case 217: + case 221: var parent_4 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 219 && parent_4.kind !== 246 && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 221 && parent_4.kind !== 248 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } return isDeclarationVisible(parent_4); - case 139: - case 138: - case 143: - case 144: case 141: case 140: + case 145: + case 146: + case 143: + case 142: if (node.flags & (32 | 64)) { return false; } - case 142: - case 146: - case 145: + case 144: + case 148: case 147: - case 136: - case 217: - case 150: - case 151: - case 153: case 149: - case 154: + case 138: + case 219: + case 152: + case 153: case 155: + case 151: case 156: case 157: case 158: + case 159: + case 160: return isDeclarationVisible(node.parent); - case 221: - case 222: + case 223: case 224: + case 226: return false; - case 135: - case 246: + case 137: + case 248: return true; - case 225: + case 227: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -11887,10 +12131,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 225) { + if (node.parent && node.parent.kind === 227) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 228) { + else if (node.parent.kind === 230) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -11965,7 +12209,7 @@ var ts; } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 209 ? node.parent.parent.parent : node.parent; + return node.kind === 211 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -11978,9 +12222,13 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1) !== 0; } + function getTypeForBindingElementParent(node) { + var symbol = getSymbolOfNode(node); + return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node); + } function getTypeForBindingElement(declaration) { var pattern = declaration.parent; - var parentType = getTypeForVariableLikeDeclaration(pattern.parent); + var parentType = getTypeForBindingElementParent(pattern.parent); if (parentType === unknownType) { return unknownType; } @@ -11991,7 +12239,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 159) { + if (pattern.kind === 161) { var name_10 = declaration.propertyName || declaration.name; type = getTypeOfPropertyOfType(parentType, name_10.text) || isNumericLiteralName(name_10.text) && getIndexTypeOfType(parentType, 1) || @@ -12025,10 +12273,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 198) { + if (declaration.parent.parent.kind === 200) { return anyType; } - if (declaration.parent.parent.kind === 199) { + if (declaration.parent.parent.kind === 201) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -12037,10 +12285,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 136) { + if (declaration.kind === 138) { var func = declaration.parent; - if (func.kind === 144 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143); + if (func.kind === 146 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -12053,7 +12301,7 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 244) { + if (declaration.kind === 246) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -12091,7 +12339,7 @@ var ts; if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; } - var elementTypes = ts.map(elements, function (e) { return e.kind === 185 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + var elementTypes = ts.map(elements, function (e) { return e.kind === 187 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); if (includePatternInType) { var result = createNewTupleType(elementTypes); result.pattern = pattern; @@ -12100,7 +12348,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern, includePatternInType) { - return pattern.kind === 159 + return pattern.kind === 161 ? getTypeFromObjectBindingPattern(pattern, includePatternInType) : getTypeFromArrayBindingPattern(pattern, includePatternInType); } @@ -12110,12 +12358,12 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 243 ? getWidenedType(type) : type; + return declaration.kind !== 245 ? getWidenedType(type) : type; } type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 136 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 138 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -12128,12 +12376,18 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 242) { + if (declaration.parent.kind === 244) { return links.type = anyType; } - if (declaration.kind === 225) { + if (declaration.kind === 227) { return links.type = checkExpression(declaration.expression); } + if (declaration.kind === 181) { + return links.type = checkExpression(declaration.right); + } + if (declaration.kind === 166) { + return checkExpressionCached(declaration.parent.right); + } if (!pushTypeResolution(symbol, 0)) { return unknownType; } @@ -12156,7 +12410,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 143) { + if (accessor.kind === 145) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -12172,8 +12426,8 @@ var ts; if (!pushTypeResolution(symbol, 0)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 143); - var setter = ts.getDeclarationOfKind(symbol, 144); + var getter = ts.getDeclarationOfKind(symbol, 145); + var setter = ts.getDeclarationOfKind(symbol, 146); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -12199,7 +12453,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 143); + var getter_1 = ts.getDeclarationOfKind(symbol, 145); error(getter_1, 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)); } } @@ -12288,9 +12542,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 212 || node.kind === 184 || - node.kind === 211 || node.kind === 171 || - node.kind === 141 || node.kind === 172) { + if (node.kind === 214 || node.kind === 186 || + node.kind === 213 || node.kind === 173 || + node.kind === 143 || node.kind === 174) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -12299,15 +12553,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 215); return appendOuterTypeParameters(undefined, declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 213 || node.kind === 212 || - node.kind === 184 || node.kind === 214) { + if (node.kind === 215 || node.kind === 214 || + node.kind === 186 || node.kind === 216) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -12412,7 +12666,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 213 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 215 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -12433,6 +12687,29 @@ var ts; } } } + function isIndependentInterface(symbol) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 215) { + if (declaration.flags & 524288) { + return false; + } + var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); + if (baseTypeNodes) { + for (var _b = 0; _b < baseTypeNodes.length; _b++) { + var node = baseTypeNodes[_b]; + if (ts.isSupportedExpressionWithTypeArguments(node)) { + var baseSymbol = resolveEntityName(node.expression, 793056, true); + if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + return false; + } + } + } + } + } + } + return true; + } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { @@ -12440,7 +12717,7 @@ var ts; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - if (outerTypeParameters || localTypeParameters) { + if (outerTypeParameters || localTypeParameters || kind === 1024 || !isIndependentInterface(symbol)) { type.flags |= 4096; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; @@ -12449,6 +12726,9 @@ var ts; type.instantiations[getTypeListId(type.typeParameters)] = type; type.target = type; type.typeArguments = type.typeParameters; + type.thisType = createType(512 | 33554432); + type.thisType.symbol = symbol; + type.thisType.constraint = getTypeWithThisArgument(type); } } return links.declaredType; @@ -12459,7 +12739,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 214); + var declaration = ts.getDeclarationOfKind(symbol, 216); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -12490,7 +12770,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 135).constraint) { + if (!ts.getDeclarationOfKind(symbol, 137).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -12523,19 +12803,79 @@ var ts; } return unknownType; } - function createSymbolTable(symbols) { - var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; - result[symbol.name] = symbol; + function isIndependentTypeReference(node) { + if (node.typeArguments) { + for (var _i = 0, _a = node.typeArguments; _i < _a.length; _i++) { + var typeNode = _a[_i]; + if (!isIndependentType(typeNode)) { + return false; + } + } } - return result; + return true; } - function createInstantiatedSymbolTable(symbols, mapper) { - var result = {}; + function isIndependentType(node) { + switch (node.kind) { + case 117: + case 130: + case 128: + case 120: + case 131: + case 103: + case 9: + return true; + case 156: + return isIndependentType(node.elementType); + case 151: + return isIndependentTypeReference(node); + } + return false; + } + function isIndependentVariableLikeDeclaration(node) { + return node.type && isIndependentType(node.type) || !node.type && !node.initializer; + } + function isIndependentFunctionLikeDeclaration(node) { + if (node.kind !== 144 && (!node.type || !isIndependentType(node.type))) { + return false; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + if (!isIndependentVariableLikeDeclaration(parameter)) { + return false; + } + } + return true; + } + function isIndependentMember(symbol) { + if (symbol.declarations && symbol.declarations.length === 1) { + var declaration = symbol.declarations[0]; + if (declaration) { + switch (declaration.kind) { + case 141: + case 140: + return isIndependentVariableLikeDeclaration(declaration); + case 143: + case 142: + case 144: + return isIndependentFunctionLikeDeclaration(declaration); + } + } + } + return false; + } + function createSymbolTable(symbols) { + var result = {}; + for (var _i = 0; _i < symbols.length; _i++) { + var symbol = symbols[_i]; + result[symbol.name] = symbol; + } + return result; + } + function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { + var result = {}; for (var _i = 0; _i < symbols.length; _i++) { var symbol = symbols[_i]; - result[symbol.name] = instantiateSymbol(symbol, mapper); + result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } return result; } @@ -12566,44 +12906,54 @@ var ts; } return type; } - function resolveClassOrInterfaceMembers(type) { - var target = resolveDeclaredMembers(type); - var members = target.symbol.members; - var callSignatures = target.declaredCallSignatures; - var constructSignatures = target.declaredConstructSignatures; - var stringIndexType = target.declaredStringIndexType; - var numberIndexType = target.declaredNumberIndexType; - var baseTypes = getBaseTypes(target); + function getTypeWithThisArgument(type, thisArgument) { + if (type.flags & 4096) { + return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + } + return type; + } + function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) { + var mapper = identityMapper; + var members = source.symbol.members; + var callSignatures = source.declaredCallSignatures; + var constructSignatures = source.declaredConstructSignatures; + var stringIndexType = source.declaredStringIndexType; + var numberIndexType = source.declaredNumberIndexType; + if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { + mapper = createTypeMapper(typeParameters, typeArguments); + members = createInstantiatedSymbolTable(source.declaredProperties, mapper, typeParameters.length === 1); + callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); + constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); + stringIndexType = instantiateType(source.declaredStringIndexType, mapper); + numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); + } + var baseTypes = getBaseTypes(source); if (baseTypes.length) { - members = createSymbolTable(target.declaredProperties); + if (members === source.symbol.members) { + members = createSymbolTable(source.declaredProperties); + } + var thisArgument = ts.lastOrUndefined(typeArguments); for (var _i = 0; _i < baseTypes.length; _i++) { var baseType = baseTypes[_i]; - addInheritedMembers(members, getPropertiesOfObjectType(baseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(baseType, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(baseType, 1)); - stringIndexType = stringIndexType || getIndexTypeOfType(baseType, 0); - numberIndexType = numberIndexType || getIndexTypeOfType(baseType, 1); + var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; + addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); + stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0); + numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1); } } setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } + function resolveClassOrInterfaceMembers(type) { + resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); + } function resolveTypeReferenceMembers(type) { - var target = resolveDeclaredMembers(type.target); - var mapper = createTypeMapper(target.typeParameters, type.typeArguments); - var members = createInstantiatedSymbolTable(target.declaredProperties, mapper); - var callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); - var constructSignatures = instantiateList(target.declaredConstructSignatures, mapper, instantiateSignature); - var stringIndexType = target.declaredStringIndexType ? instantiateType(target.declaredStringIndexType, mapper) : undefined; - var numberIndexType = target.declaredNumberIndexType ? instantiateType(target.declaredNumberIndexType, mapper) : undefined; - ts.forEach(getBaseTypes(target), function (baseType) { - var instantiatedBaseType = instantiateType(baseType, mapper); - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1); - }); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var source = resolveDeclaredMembers(type.target); + var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); + var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? + type.typeArguments : ts.concatenate(type.typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); @@ -12652,7 +13002,8 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, true))); + var arrayElementType = getUnionType(type.elementTypes, true); + var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -12754,7 +13105,14 @@ var ts; var constructSignatures; var stringIndexType; var numberIndexType; - if (symbol.flags & 2048) { + if (type.target) { + members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false); + callSignatures = instantiateList(getSignaturesOfType(type.target, 0), type.mapper, instantiateSignature); + constructSignatures = instantiateList(getSignaturesOfType(type.target, 1), type.mapper, instantiateSignature); + stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0), type.mapper); + numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1), type.mapper); + } + else if (symbol.flags & 2048) { members = symbol.members; callSignatures = getSignaturesOfSymbol(members["__call"]); constructSignatures = getSignaturesOfSymbol(members["__new"]); @@ -12790,7 +13148,10 @@ var ts; } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & (1024 | 2048)) { + if (type.flags & 4096) { + resolveTypeReferenceMembers(type); + } + else if (type.flags & (1024 | 2048)) { resolveClassOrInterfaceMembers(type); } else if (type.flags & 65536) { @@ -12805,9 +13166,6 @@ var ts; else if (type.flags & 32768) { resolveIntersectionTypeMembers(type); } - else { - resolveTypeReferenceMembers(type); - } } return type; } @@ -13014,7 +13372,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 142 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 144 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -13045,7 +13403,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 148) { + if (declaration.type.kind === 150) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -13055,8 +13413,8 @@ var ts; } } else { - if (declaration.kind === 143 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 144); + if (declaration.kind === 145 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 146); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -13074,19 +13432,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 150: - case 151: - case 211: - case 141: - case 140: + case 152: + case 153: + case 213: + case 143: case 142: + case 144: + case 147: + case 148: + case 149: case 145: case 146: - case 147: - case 143: - case 144: - case 171: - case 172: + case 173: + case 174: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -13098,6 +13456,16 @@ var ts; } return result; } + function resolveExternalModuleTypeByLiteral(name) { + var moduleSym = resolveExternalModuleName(name, name); + if (moduleSym) { + var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); + if (resolvedModuleSymbol) { + return getTypeOfSymbol(resolvedModuleSymbol); + } + } + return anyType; + } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3)) { @@ -13156,7 +13524,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 142 || signature.declaration.kind === 146; + var isConstructor = signature.declaration.kind === 144 || signature.declaration.kind === 148; var type = createObjectType(65536 | 262144); type.members = emptySymbols; type.properties = emptyArray; @@ -13170,7 +13538,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 126 : 128; + var syntaxKind = kind === 1 ? 128 : 130; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -13199,30 +13567,33 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 137).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137).parent); } function getTypeListId(types) { - switch (types.length) { - case 1: - return "" + types[0].id; - case 2: - return types[0].id + "," + types[1].id; - default: - var result = ""; - for (var i = 0; i < types.length; i++) { - if (i > 0) { - result += ","; + if (types) { + switch (types.length) { + case 1: + return "" + types[0].id; + case 2: + return types[0].id + "," + types[1].id; + default: + var result = ""; + for (var i = 0; i < types.length; i++) { + if (i > 0) { + result += ","; + } + result += types[i].id; } - result += types[i].id; - } - return result; + return result; + } } + return ""; } function getPropagatingFlagsOfTypes(types) { var result = 0; @@ -13236,7 +13607,7 @@ var ts; var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 | getPropagatingFlagsOfTypes(typeArguments); + var flags = 4096 | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -13252,13 +13623,13 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 137; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 149 && n.typeName.kind === 67) { + if (n.kind === 151 && n.typeName.kind === 69) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); @@ -13325,7 +13696,7 @@ var ts; function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var typeNameOrExpression = node.kind === 149 ? node.typeName : + var typeNameOrExpression = node.kind === 151 ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; @@ -13351,9 +13722,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 212: - case 213: + case 214: case 215: + case 217: return declaration; } } @@ -13390,10 +13761,13 @@ var ts; return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056, undefined), arity); } function getExportedTypeFromNamespace(namespace, name) { - var namespaceSymbol = getGlobalSymbol(namespace, 1536, undefined); - var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056); + var typeSymbol = getExportedSymbolFromNamespace(namespace, name); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } + function getExportedSymbolFromNamespace(namespace, name) { + var namespaceSymbol = getGlobalSymbol(namespace, 1536, undefined); + return namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 | 107455); + } function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } @@ -13403,17 +13777,17 @@ var ts; ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) : emptyObjectType; } - function createTypeFromGenericGlobalType(genericGlobalType, elementType) { - return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, [elementType]) : emptyObjectType; + function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { + return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; } function createIterableType(elementType) { - return createTypeFromGenericGlobalType(globalIterableType, elementType); + return createTypeFromGenericGlobalType(globalIterableType, [elementType]); } function createIterableIteratorType(elementType) { - return createTypeFromGenericGlobalType(globalIterableIteratorType, elementType); + return createTypeFromGenericGlobalType(globalIterableIteratorType, [elementType]); } function createArrayType(elementType) { - return createTypeFromGenericGlobalType(globalArrayType, elementType); + return createTypeFromGenericGlobalType(globalArrayType, [elementType]); } function getTypeFromArrayTypeNode(node) { var links = getNodeLinks(node); @@ -13570,46 +13944,66 @@ var ts; } return links.resolvedType; } + function getThisType(node) { + var container = ts.getThisContainer(node, false); + var parent = container && container.parent; + if (parent && (ts.isClassLike(parent) || parent.kind === 215)) { + if (!(container.flags & 128)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; + } + } + error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); + return unknownType; + } + function getTypeFromThisTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getThisType(node); + } + return links.resolvedType; + } function getTypeFromTypeNode(node) { switch (node.kind) { - case 115: + case 117: return anyType; - case 128: + case 130: return stringType; - case 126: + case 128: return numberType; - case 118: + case 120: return booleanType; - case 129: + case 131: return esSymbolType; - case 101: + case 103: return voidType; + case 97: + return getTypeFromThisTypeNode(node); case 9: return getTypeFromStringLiteral(node); - case 149: + case 151: return getTypeFromTypeReference(node); - case 148: + case 150: return booleanType; - case 186: + case 188: return getTypeFromTypeReference(node); - case 152: - return getTypeFromTypeQueryNode(node); case 154: + return getTypeFromTypeQueryNode(node); + case 156: return getTypeFromArrayTypeNode(node); - case 155: + case 157: return getTypeFromTupleTypeNode(node); - case 156: + case 158: return getTypeFromUnionTypeNode(node); - case 157: + case 159: return getTypeFromIntersectionTypeNode(node); - case 158: + case 160: return getTypeFromTypeNode(node.type); - case 150: - case 151: + case 152: case 153: + case 155: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 67: - case 133: + case 69: + case 135: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -13713,7 +14107,7 @@ var ts; type: instantiateType(signature.typePredicate.type, mapper) }; } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -13745,21 +14139,13 @@ var ts; mapper.instantiations = []; } var result = createObjectType(65536 | 131072, type.symbol); - result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); - result.members = createSymbolTable(result.properties); - result.callSignatures = instantiateList(getSignaturesOfType(type, 0), mapper, instantiateSignature); - result.constructSignatures = instantiateList(getSignaturesOfType(type, 1), mapper, instantiateSignature); - var stringIndexType = getIndexTypeOfType(type, 0); - var numberIndexType = getIndexTypeOfType(type, 1); - if (stringIndexType) - result.stringIndexType = instantiateType(stringIndexType, mapper); - if (numberIndexType) - result.numberIndexType = instantiateType(numberIndexType, mapper); + result.target = type; + result.mapper = mapper; mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { - if (mapper !== identityMapper) { + if (type && mapper !== identityMapper) { if (type.flags & 512) { return mapper(type); } @@ -13783,27 +14169,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 171: - case 172: + case 173: + case 174: return isContextSensitiveFunctionLikeDeclaration(node); - case 163: + case 165: return ts.forEach(node.properties, isContextSensitive); - case 162: + case 164: return ts.forEach(node.elements, isContextSensitive); - case 180: + case 182: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 179: - return node.operatorToken.kind === 51 && + case 181: + return node.operatorToken.kind === 52 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 243: + case 245: return isContextSensitive(node.initializer); - case 141: - case 140: + case 143: + case 142: return isContextSensitiveFunctionLikeDeclaration(node); - case 170: + case 172: return isContextSensitive(node.expression); } return false; @@ -13956,7 +14342,7 @@ var ts; } else { if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { return result; } } @@ -13978,7 +14364,7 @@ var ts; var result; if (source.flags & 80896 && target.flags & 80896) { if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, false)) { + if (result = typeArgumentsRelatedTo(source, target, false)) { return result; } } @@ -14088,9 +14474,14 @@ var ts; } return result; } - function typesRelatedTo(sources, targets, reportErrors) { + function typeArgumentsRelatedTo(source, target, reportErrors) { + var sources = source.typeArguments || emptyArray; + var targets = target.typeArguments || emptyArray; + if (sources.length !== targets.length && relation === identityRelation) { + return 0; + } var result = -1; - for (var i = 0, len = sources.length; i < len; i++) { + for (var i = 0; i < targets.length; i++) { var related = isRelatedTo(sources[i], targets[i], reportErrors); if (!related) { return 0; @@ -14741,22 +15132,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 139: - case 138: + case 141: + case 140: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 136: + case 138: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 211: - case 141: - case 140: + case 213: case 143: - case 144: - case 171: - case 172: + case 142: + case 145: + case 146: + case 173: + case 174: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -14852,9 +15243,10 @@ var ts; } } 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++) { + var sourceTypes = source.typeArguments || emptyArray; + var targetTypes = target.typeArguments || emptyArray; + var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; + for (var i = 0; i < count; i++) { inferFromTypes(sourceTypes[i], targetTypes[i]); } } @@ -15008,10 +15400,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 152: + case 154: return true; - case 67: - case 133: + case 69: + case 135: node = node.parent; continue; default: @@ -15051,12 +15443,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 55 && node.operatorToken.kind <= 66) { + if (node.operatorToken.kind >= 56 && node.operatorToken.kind <= 68) { var n = node.left; - while (n.kind === 170) { + while (n.kind === 172) { n = n.expression; } - if (n.kind === 67 && getResolvedSymbol(n) === symbol) { + if (n.kind === 69 && getResolvedSymbol(n) === symbol) { return true; } } @@ -15070,55 +15462,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 179: + case 181: return isAssignedInBinaryExpression(node); - case 209: - case 161: + case 211: + case 163: return isAssignedInVariableDeclaration(node); - case 159: - case 160: + case 161: case 162: - case 163: case 164: case 165: case 166: case 167: + case 168: case 169: - case 187: - case 170: - case 177: - case 173: - case 176: - case 174: + case 171: + case 189: + case 172: + case 179: case 175: case 178: - case 182: + case 176: + case 177: case 180: - case 183: - case 190: - case 191: + case 184: + case 182: + case 185: + case 192: case 193: - case 194: case 195: case 196: case 197: case 198: case 199: - case 202: - case 203: + case 200: + case 201: case 204: - case 239: - case 240: case 205: case 206: - case 207: + case 241: case 242: - case 231: - case 232: - case 236: - case 237: + case 207: + case 208: + case 209: + case 244: case 233: + case 234: case 238: + case 239: + case 235: + case 240: return ts.forEachChild(node, isAssignedIn); } return false; @@ -15133,34 +15525,34 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 194: + case 196: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 180: + case 182: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 179: + case 181: if (child === node.right) { - if (node.operatorToken.kind === 50) { + if (node.operatorToken.kind === 51) { narrowedType = narrowType(type, node.left, true); } - else if (node.operatorToken.kind === 51) { + else if (node.operatorToken.kind === 52) { narrowedType = narrowType(type, node.left, false); } } break; - case 246: - case 216: - case 211: - case 141: - case 140: + case 248: + case 218: + case 213: case 143: - case 144: case 142: + case 145: + case 146: + case 144: break loop; } if (narrowedType !== type) { @@ -15174,12 +15566,12 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 174 || expr.right.kind !== 9) { + if (expr.left.kind !== 176 || expr.right.kind !== 9) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 67 || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 69 || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; @@ -15225,7 +15617,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 69 || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -15289,27 +15681,27 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 166: + case 168: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 170: + case 172: return narrowType(type, expr.expression, assumeTrue); - case 179: + case 181: var operator = expr.operatorToken.kind; if (operator === 32 || operator === 33) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 50) { + else if (operator === 51) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 51) { + else if (operator === 52) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 89) { + else if (operator === 91) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 177: - if (expr.operator === 48) { + case 179: + if (expr.operator === 49) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -15321,7 +15713,7 @@ var ts; var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 172) { + if (container.kind === 174) { if (languageVersion < 2) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -15352,15 +15744,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 242) { + symbol.valueDeclaration.parent.kind === 244) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 210) { + while (container.kind !== 212) { container = container.parent; } container = container.parent; - if (container.kind === 191) { + if (container.kind === 193) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -15378,7 +15770,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 139 || container.kind === 142) { + if (container.kind === 141 || container.kind === 144) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -15389,29 +15781,29 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 172) { + if (container.kind === 174) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 216: + case 218: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 215: + case 217: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 142: + case 144: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 139: - case 138: + case 141: + case 140: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 134: + case 136: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -15420,27 +15812,27 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); + return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } return anyType; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 136) { + if (n.kind === 138) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 166 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 168 && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 172) { + while (container && container.kind === 174) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -15466,7 +15858,7 @@ var ts; return unknownType; } if (!canUseSuperExpression) { - if (container && container.kind === 134) { + if (container && container.kind === 136) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -15477,7 +15869,7 @@ var ts; } return unknownType; } - if (container.kind === 142 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 144 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -15489,24 +15881,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 142; + return container.kind === 144; } else { if (container && ts.isClassLike(container.parent)) { if (container.flags & 128) { - return container.kind === 141 || - container.kind === 140 || - container.kind === 143 || - container.kind === 144; + return container.kind === 143 || + container.kind === 142 || + container.kind === 145 || + container.kind === 146; } else { - return container.kind === 141 || + return container.kind === 143 || + container.kind === 142 || + container.kind === 145 || + container.kind === 146 || + container.kind === 141 || container.kind === 140 || - container.kind === 143 || - container.kind === 144 || - container.kind === 139 || - container.kind === 138 || - container.kind === 142; + container.kind === 144; } } } @@ -15540,7 +15932,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 136) { + if (declaration.kind === 138) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -15573,7 +15965,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 136 && node.parent.initializer === node) { + if (node.parent.kind === 138 && node.parent.initializer === node) { return true; } node = node.parent; @@ -15582,8 +15974,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 142 || - functionDecl.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144))) { + functionDecl.kind === 144 || + functionDecl.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -15602,7 +15994,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 168) { + if (template.parent.kind === 170) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -15610,12 +16002,12 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 55 && operator <= 66) { + if (operator >= 56 && operator <= 68) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 51) { + else if (operator === 52) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); @@ -15702,7 +16094,7 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxExpression(expr) { - if (expr.parent.kind === 236) { + if (expr.parent.kind === 238) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -15712,7 +16104,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 237) { + if (expr.kind === 239) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -15730,38 +16122,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 209: - case 136: - case 139: + case 211: case 138: - case 161: + case 141: + case 140: + case 163: return getContextualTypeForInitializerExpression(node); - case 172: - case 202: + case 174: + case 204: return getContextualTypeForReturnExpression(node); - case 182: + case 184: return getContextualTypeForYieldOperand(parent); - case 166: - case 167: - return getContextualTypeForArgument(parent, node); + case 168: case 169: - case 187: + return getContextualTypeForArgument(parent, node); + case 171: + case 189: return getTypeFromTypeNode(parent.type); - case 179: + case 181: return getContextualTypeForBinaryOperand(node); - case 243: + case 245: return getContextualTypeForObjectLiteralElement(parent); - case 162: + case 164: return getContextualTypeForElementExpression(node); - case 180: + case 182: return getContextualTypeForConditionalOperand(node); - case 188: - ts.Debug.assert(parent.parent.kind === 181); + case 190: + ts.Debug.assert(parent.parent.kind === 183); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 170: + case 172: return getContextualType(parent); - case 238: - case 237: + case 240: + case 239: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -15776,7 +16168,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 171 || node.kind === 172; + return node.kind === 173 || node.kind === 174; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -15784,7 +16176,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -15824,13 +16216,13 @@ var ts; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 179 && parent.operatorToken.kind === 55 && parent.left === node) { + if (parent.kind === 181 && parent.operatorToken.kind === 56 && parent.left === node) { return true; } - if (parent.kind === 243) { + if (parent.kind === 245) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 162) { + if (parent.kind === 164) { return isAssignmentTarget(parent); } return false; @@ -15840,8 +16232,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 161 && !!node.initializer) || - (node.kind === 179 && node.operatorToken.kind === 55); + return (node.kind === 163 && !!node.initializer) || + (node.kind === 181 && node.operatorToken.kind === 56); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -15850,7 +16242,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 183) { + if (inDestructuringPattern && e.kind === 185) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -15862,7 +16254,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 183; + hasSpreadElement = hasSpreadElement || e.kind === 185; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -15873,7 +16265,7 @@ var ts; var contextualType = getContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 160 || pattern.kind === 162)) { + if (pattern && (pattern.kind === 162 || pattern.kind === 164)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -15881,7 +16273,7 @@ var ts; elementTypes.push(contextualType.elementTypes[i]); } else { - if (patternElement.kind !== 185) { + if (patternElement.kind !== 187) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -15896,7 +16288,7 @@ var ts; return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 134 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 136 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); @@ -15921,35 +16313,37 @@ var ts; return links.resolvedType; } function checkObjectLiteral(node, contextualMapper) { - checkGrammarObjectLiteralExpression(node); + var inDestructuringPattern = isAssignmentTarget(node); + checkGrammarObjectLiteralExpression(node, inDestructuringPattern); var propertiesTable = {}; var propertiesArray = []; var contextualType = getContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 159 || contextualType.pattern.kind === 163); - var inDestructuringPattern = isAssignmentTarget(node); + (contextualType.pattern.kind === 161 || contextualType.pattern.kind === 165); var typeFlags = 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 243 || - memberDecl.kind === 244 || + if (memberDecl.kind === 245 || + memberDecl.kind === 246 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 243) { + if (memberDecl.kind === 245) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 141) { + else if (memberDecl.kind === 143) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 244); + ts.Debug.assert(memberDecl.kind === 246); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 | 67108864 | member.flags, member.name); if (inDestructuringPattern) { - if (memberDecl.kind === 243 && hasDefaultValue(memberDecl.initializer)) { + var isOptional = (memberDecl.kind === 245 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 246 && memberDecl.objectAssignmentInitializer); + if (isOptional) { prop.flags |= 536870912; } } @@ -15972,7 +16366,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 143 || memberDecl.kind === 144); + ts.Debug.assert(memberDecl.kind === 145 || memberDecl.kind === 146); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -16028,7 +16422,7 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 67) { + if (lhs.kind === 69) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && @@ -16045,17 +16439,17 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 238: + case 240: checkJsxExpression(child); break; - case 231: + case 233: checkJsxElement(child); break; - case 232: + case 234: checkJsxSelfClosingElement(child); break; default: - ts.Debug.assert(child.kind === 234); + ts.Debug.assert(child.kind === 236); } } return jsxElementType || anyType; @@ -16064,7 +16458,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 133) { + if (tagName.kind === 135) { return false; } else { @@ -16165,12 +16559,14 @@ var ts; var valueSymbol = resolveJsxTagName(node); if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4; - getSymbolLinks(valueSymbol).referenced = true; + if (valueSymbol.flags & 8388608) { + markAliasSymbolAsReferenced(valueSymbol); + } } return valueSymbol || unknownSymbol; } function resolveJsxTagName(node) { - if (node.tagName.kind === 67) { + if (node.tagName.kind === 69) { var tag = node.tagName; var sym = getResolvedSymbol(tag); return sym.exportSymbol || sym; @@ -16310,11 +16706,11 @@ var ts; var nameTable = {}; var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 236) { + if (node.attributes[i].kind === 238) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 237); + ts.Debug.assert(node.attributes[i].kind === 239); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -16340,7 +16736,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 139; + return s.valueDeclaration ? s.valueDeclaration.kind : 141; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -16348,11 +16744,11 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 93) { - var errorNode = node.kind === 164 ? + if (left.kind === 95) { + var errorNode = node.kind === 166 ? node.name : node.right; - if (getDeclarationKindFromSymbol(prop) !== 141) { + if (getDeclarationKindFromSymbol(prop) !== 143) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -16373,7 +16769,7 @@ var ts; } return true; } - if (left.kind === 93) { + if (left.kind === 95) { return true; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -16383,6 +16779,9 @@ var ts; if (flags & 128) { return true; } + if (type.flags & 33554432) { + type = getConstraintOfTypeParameter(type); + } if (!(getTargetType(type).flags & (1024 | 2048) && hasBaseType(type, enclosingClass))) { error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); return false; @@ -16407,18 +16806,18 @@ var ts; var prop = getPropertyOfType(apparentType, right.text); if (!prop) { if (right.text) { - error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type)); + error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type.flags & 33554432 ? apparentType : type)); } return unknownType; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { - checkClassPropertyAccess(node, left, type, prop); + checkClassPropertyAccess(node, left, apparentType, prop); } return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 164 + var left = node.kind === 166 ? node.expression : node.left; var type = checkExpression(left); @@ -16433,7 +16832,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 167 && node.parent.expression === node) { + if (node.parent.kind === 169 && 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); @@ -16492,6 +16891,12 @@ var ts; if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } + if (indexArgumentExpression.kind === 167 || indexArgumentExpression.kind === 166) { + var value = getConstantValue(indexArgumentExpression); + if (value !== undefined) { + return value.toString(); + } + } if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { var rightHandSideName = indexArgumentExpression.name.text; return ts.getPropertyNameForKnownSymbolName(rightHandSideName); @@ -16529,10 +16934,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 168) { + if (node.kind === 170) { checkExpression(node.template); } - else if (node.kind !== 137) { + else if (node.kind !== 139) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -16583,7 +16988,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 183) { + if (arg && arg.kind === 185) { return i; } } @@ -16595,11 +17000,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 168) { + if (node.kind === 170) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 181) { + if (tagExpression.template.kind === 183) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -16611,7 +17016,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 137) { + else if (node.kind === 139) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); @@ -16619,7 +17024,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 167); + ts.Debug.assert(callExpression.kind === 169); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -16672,7 +17077,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 185) { + if (arg === undefined || arg.kind !== 187) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -16719,7 +17124,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 185) { + if (arg === undefined || arg.kind !== 187) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -16738,16 +17143,16 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 168) { + if (node.kind === 170) { var template = node.template; args = [undefined]; - if (template.kind === 181) { + if (template.kind === 183) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 137) { + else if (node.kind === 139) { return undefined; } else { @@ -16756,18 +17161,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 137) { + if (node.kind === 139) { switch (node.parent.kind) { - case 212: - case 184: + case 214: + case 186: return 1; - case 139: - return 2; case 141: + return 2; case 143: - case 144: + case 145: + case 146: + if (languageVersion === 0) { + return 2; + } return signature.parameters.length >= 3 ? 3 : 2; - case 136: + case 138: return 3; } } @@ -16777,20 +17185,20 @@ var ts; } function getEffectiveDecoratorFirstArgumentType(node) { switch (node.kind) { - case 212: - case 184: + case 214: + case 186: var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 136: + case 138: node = node.parent; - if (node.kind === 142) { + if (node.kind === 144) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } - case 139: case 141: case 143: - case 144: + case 145: + case 146: return getParentTypeOfClassElement(node); default: ts.Debug.fail("Unsupported decorator target."); @@ -16799,25 +17207,25 @@ var ts; } function getEffectiveDecoratorSecondArgumentType(node) { switch (node.kind) { - case 212: + case 214: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 136: + case 138: node = node.parent; - if (node.kind === 142) { + if (node.kind === 144) { return anyType; } - case 139: case 141: case 143: - case 144: + case 145: + case 146: var element = node; switch (element.name.kind) { - case 67: + case 69: case 8: case 9: return getStringLiteralType(element.name); - case 134: + case 136: var nameType = checkComputedPropertyName(element.name); if (allConstituentTypesHaveKind(nameType, 16777216)) { return nameType; @@ -16836,17 +17244,17 @@ var ts; } function getEffectiveDecoratorThirdArgumentType(node) { switch (node.kind) { - case 212: + case 214: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 136: + case 138: return numberType; - case 139: + case 141: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 141: case 143: - case 144: + case 145: + case 146: var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); default: @@ -16868,26 +17276,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 137) { + if (node.kind === 139) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 168) { + else if (argIndex === 0 && node.kind === 170) { return globalTemplateStringsArrayType; } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 137 || - (argIndex === 0 && node.kind === 168)) { + if (node.kind === 139 || + (argIndex === 0 && node.kind === 170)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 137) { + if (node.kind === 139) { return node.expression; } - else if (argIndex === 0 && node.kind === 168) { + else if (argIndex === 0 && node.kind === 170) { return node.template; } else { @@ -16895,12 +17303,12 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 168; - var isDecorator = node.kind === 137; + var isTaggedTemplate = node.kind === 170; + var isDecorator = node.kind === 139; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; - if (node.expression.kind !== 93) { + if (node.expression.kind !== 95) { ts.forEach(typeArguments, checkSourceElement); } } @@ -17038,7 +17446,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 93) { + if (node.expression.kind === 95) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -17127,16 +17535,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 212: - case 184: + case 214: + case 186: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 136: + case 138: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 139: - return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; case 141: + return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; case 143: - case 144: + case 145: + case 146: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -17164,16 +17572,16 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 166) { + if (node.kind === 168) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 167) { + else if (node.kind === 169) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 168) { + else if (node.kind === 170) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 137) { + else if (node.kind === 139) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -17185,21 +17593,24 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 93) { + if (node.expression.kind === 95) { return voidType; } - if (node.kind === 167) { + if (node.kind === 169) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 142 && - declaration.kind !== 146 && - declaration.kind !== 151) { + declaration.kind !== 144 && + declaration.kind !== 148 && + declaration.kind !== 153) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } return anyType; } } + if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node)) { + return resolveExternalModuleTypeByLiteral(node.arguments[0]); + } return getReturnTypeOfSignature(signature); } function checkTaggedTemplateExpression(node) { @@ -17234,10 +17645,22 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } } + function assignBindingElementTypes(node) { + if (ts.isBindingPattern(node.name)) { + for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 187) { + getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); + assignBindingElementTypes(element); + } + } + } + } function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { var links = getSymbolLinks(parameter); if (!links.type) { links.type = instantiateType(contextualType, mapper); + assignBindingElementTypes(parameter.valueDeclaration); } else if (isInferentialContext(mapper)) { inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); @@ -17258,7 +17681,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 190) { + if (func.body.kind !== 192) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -17362,7 +17785,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 206); + return (body.statements.length === 1) && (body.statements[0].kind === 208); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -17371,7 +17794,7 @@ var ts; if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 190) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192) { return; } var bodyBlock = func.body; @@ -17384,9 +17807,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 !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 171) { + if (!hasGrammarError && node.kind === 173) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -17422,14 +17845,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 141 && node.kind !== 140) { + if (produceDiagnostics && node.kind !== 143 && node.kind !== 142) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -17446,7 +17869,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 190) { + if (node.body.kind === 192) { checkSourceElement(node.body); } else { @@ -17478,17 +17901,17 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 67: { + case 69: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 164: { + case 166: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 165: + case 167: return true; - case 170: + case 172: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -17496,12 +17919,12 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 67: - case 164: { + case 69: + case 166: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; } - case 165: { + case 167: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 9) { @@ -17511,7 +17934,7 @@ var ts; } return false; } - case 170: + case 172: return isConstVariableReference(n.expression); default: return false; @@ -17556,15 +17979,15 @@ var ts; switch (node.operator) { case 35: case 36: - case 49: + case 50: if (someConstituentTypeHasKind(operandType, 16777216)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 48: + case 49: return booleanType; - case 40: case 41: + case 42: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); @@ -17619,21 +18042,21 @@ var ts; function isConstEnumSymbol(symbol) { return (symbol.flags & 128) !== 0; } - function checkInstanceOfExpression(node, leftType, rightType) { + function checkInstanceOfExpression(left, right, leftType, rightType) { if (allConstituentTypesHaveKind(leftType, 16777726)) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); + error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; } - function checkInExpression(node, leftType, rightType) { + function checkInExpression(left, right, leftType, rightType) { if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 16777216)) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); + error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } @@ -17641,7 +18064,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 243 || p.kind === 244) { + if (p.kind === 245 || p.kind === 246) { var name_13 = p.name; var type = isTypeAny(sourceType) ? sourceType @@ -17649,7 +18072,12 @@ var ts; isNumericLiteralName(name_13.text) && getIndexTypeOfType(sourceType, 1) || getIndexTypeOfType(sourceType, 0); if (type) { - checkDestructuringAssignment(p.initializer || name_13, type); + if (p.kind === 246) { + checkDestructuringAssignment(p, type); + } + else { + checkDestructuringAssignment(p.initializer || name_13, type); + } } else { error(name_13, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_13)); @@ -17666,8 +18094,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 185) { - if (e.kind !== 183) { + if (e.kind !== 187) { + if (e.kind !== 185) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -17692,7 +18120,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 179 && restExpression.operatorToken.kind === 55) { + if (restExpression.kind === 181 && restExpression.operatorToken.kind === 56) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -17704,15 +18132,26 @@ var ts; } return sourceType; } - function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 179 && target.operatorToken.kind === 55) { + function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { + var target; + if (exprOrAssignment.kind === 246) { + var prop = exprOrAssignment; + if (prop.objectAssignmentInitializer) { + checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); + } + target = exprOrAssignment.name; + } + else { + target = exprOrAssignment; + } + if (target.kind === 181 && target.operatorToken.kind === 56) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 163) { + if (target.kind === 165) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 162) { + if (target.kind === 164) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -17725,33 +18164,38 @@ var ts; return sourceType; } function checkBinaryExpression(node, contextualMapper) { - var operator = node.operatorToken.kind; - if (operator === 55 && (node.left.kind === 163 || node.left.kind === 162)) { - return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); + return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); + } + function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { + var operator = operatorToken.kind; + if (operator === 56 && (left.kind === 165 || left.kind === 164)) { + return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } - var leftType = checkExpression(node.left, contextualMapper); - var rightType = checkExpression(node.right, contextualMapper); + var leftType = checkExpression(left, contextualMapper); + var rightType = checkExpression(right, contextualMapper); switch (operator) { case 37: - case 58: case 38: case 59: - case 39: case 60: - case 36: - case 57: - case 42: + case 39: case 61: - case 43: + case 40: case 62: - case 44: + case 36: + case 58: + case 43: case 63: - case 46: + case 44: + case 64: + case 45: case 65: case 47: + case 67: + case 48: + case 68: + case 46: case 66: - case 45: - case 64: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -17759,19 +18203,19 @@ var ts; var suggestedOperator; if ((leftType.flags & 8) && (rightType.flags & 8) && - (suggestedOperator = getSuggestedBooleanOperator(node.operatorToken.kind)) !== undefined) { - error(node, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(node.operatorToken.kind), ts.tokenToString(suggestedOperator)); + (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { + error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); } else { - var leftOk = checkArithmeticOperandType(node.left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(node.right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); if (leftOk && rightOk) { checkAssignmentOperator(numberType); } } return numberType; case 35: - case 56: + case 57: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -17795,7 +18239,7 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 56) { + if (operator === 57) { checkAssignmentOperator(resultType); } return resultType; @@ -17814,23 +18258,23 @@ var ts; reportOperatorError(); } return booleanType; - case 89: - return checkInstanceOfExpression(node, leftType, rightType); - case 88: - return checkInExpression(node, leftType, rightType); - case 50: - return rightType; + case 91: + return checkInstanceOfExpression(left, right, leftType, rightType); + case 90: + return checkInExpression(left, right, leftType, rightType); case 51: + return rightType; + case 52: return getUnionType([leftType, rightType]); - case 55: + case 56: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); case 24: return rightType; } function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? node.left : - someConstituentTypeHasKind(rightType, 16777216) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? left : + someConstituentTypeHasKind(rightType, 16777216) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -17840,29 +18284,29 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 46: - case 65: - return 51; case 47: - case 66: + case 67: + return 52; + case 48: + case 68: return 33; - case 45: - case 64: - return 50; + case 46: + case 66: + return 51; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 55 && operator <= 66) { - 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 (produceDiagnostics && operator >= 56 && operator <= 68) { + var ok = checkReferenceExpression(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); + checkTypeAssignableTo(valueType, leftType, left, undefined); } } } function reportOperatorError() { - error(node, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(node.operatorToken.kind), typeToString(leftType), typeToString(rightType)); + error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); } } function isYieldExpressionInClass(node) { @@ -17938,14 +18382,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 134) { + if (node.name.kind === 136) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 134) { + if (node.name.kind === 136) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -17968,7 +18412,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 133) { + if (node.kind === 135) { type = checkQualifiedName(node); } else { @@ -17976,9 +18420,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 164 && node.parent.expression === node) || - (node.parent.kind === 165 && node.parent.expression === node) || - ((node.kind === 67 || node.kind === 133) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 166 && node.parent.expression === node) || + (node.parent.kind === 167 && node.parent.expression === node) || + ((node.kind === 69 || node.kind === 135) && 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); } @@ -17991,78 +18435,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 67: + case 69: return checkIdentifier(node); - case 95: + case 97: return checkThisExpression(node); - case 93: + case 95: return checkSuperExpression(node); - case 91: + case 93: return nullType; - case 97: - case 82: + case 99: + case 84: return booleanType; case 8: return checkNumericLiteral(node); - case 181: + case 183: return checkTemplateExpression(node); case 9: case 11: return stringType; case 10: return globalRegExpType; - case 162: - return checkArrayLiteral(node, contextualMapper); - case 163: - return checkObjectLiteral(node, contextualMapper); case 164: - return checkPropertyAccessExpression(node); + return checkArrayLiteral(node, contextualMapper); case 165: - return checkIndexedAccess(node); + return checkObjectLiteral(node, contextualMapper); case 166: + return checkPropertyAccessExpression(node); case 167: - return checkCallExpression(node); + return checkIndexedAccess(node); case 168: - return checkTaggedTemplateExpression(node); + case 169: + return checkCallExpression(node); case 170: + return checkTaggedTemplateExpression(node); + case 172: return checkExpression(node.expression, contextualMapper); - case 184: + case 186: return checkClassExpression(node); - case 171: - case 172: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 173: case 174: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 176: return checkTypeOfExpression(node); - case 169: - case 187: + case 171: + case 189: return checkAssertion(node); - case 173: - return checkDeleteExpression(node); case 175: + return checkDeleteExpression(node); + case 177: return checkVoidExpression(node); - case 176: + case 178: return checkAwaitExpression(node); - case 177: + case 179: return checkPrefixUnaryExpression(node); - case 178: + case 180: return checkPostfixUnaryExpression(node); - case 179: + case 181: return checkBinaryExpression(node, contextualMapper); - case 180: + case 182: return checkConditionalExpression(node, contextualMapper); - case 183: - return checkSpreadElementExpression(node, contextualMapper); case 185: + return checkSpreadElementExpression(node, contextualMapper); + case 187: return undefinedType; - case 182: + case 184: return checkYieldExpression(node); - case 238: + case 240: return checkJsxExpression(node); - case 231: + case 233: return checkJsxElement(node); - case 232: + case 234: return checkJsxSelfClosingElement(node); - case 233: + case 235: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -18083,7 +18527,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 142 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 144 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -18098,15 +18542,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 141 || - node.kind === 211 || - node.kind === 171; + return node.kind === 143 || + node.kind === 213 || + node.kind === 173; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 67 && + if (param.name.kind === 69 && param.name.text === parameter.text) { return i; } @@ -18116,30 +18560,30 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { - case 172: - case 145: - case 211: - case 171: - case 150: - case 141: - case 140: - return node === node.parent.type; - } - return false; - } - function checkSignatureDeclaration(node) { - if (node.kind === 147) { + case 174: + case 147: + case 213: + case 173: + case 152: + case 143: + case 142: + return node === node.parent.type; + } + return false; + } + function checkSignatureDeclaration(node) { + if (node.kind === 149) { checkGrammarIndexSignature(node); } - else if (node.kind === 150 || node.kind === 211 || node.kind === 151 || - node.kind === 145 || node.kind === 142 || - node.kind === 146) { + else if (node.kind === 152 || node.kind === 213 || node.kind === 153 || + node.kind === 147 || node.kind === 144 || + node.kind === 148) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 148) { + if (node.type.kind === 150) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -18158,19 +18602,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 159 || - param.name.kind === 160) { + if (param.name.kind === 161 || + param.name.kind === 162) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 67 && + if (element.name.kind === 69 && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 160 || - element.name.kind === 159) { + else if (element.name.kind === 162 || + element.name.kind === 161) { checkBindingPattern(element.name); } } @@ -18194,10 +18638,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 146: + case 148: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 145: + case 147: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -18219,7 +18663,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 213) { + if (node.kind === 215) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -18234,7 +18678,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 128: + case 130: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -18242,7 +18686,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 126: + case 128: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -18282,7 +18726,7 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 166 && n.expression.kind === 93; + return n.kind === 168 && n.expression.kind === 95; } function containsSuperCallAsComputedPropertyName(n) { return n.name && containsSuperCall(n.name); @@ -18300,15 +18744,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 95) { + if (n.kind === 97) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 171 && n.kind !== 211) { + else if (n.kind !== 173 && n.kind !== 213) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 139 && + return n.kind === 141 && !(n.flags & 128) && !!n.initializer; } @@ -18328,7 +18772,7 @@ var ts; var superCallStatement; for (var _i = 0; _i < statements.length; _i++) { var statement = statements[_i]; - if (statement.kind === 193 && isSuperCallExpression(statement.expression)) { + if (statement.kind === 195 && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; } @@ -18352,13 +18796,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 143) { + if (node.kind === 145) { 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 === 143 ? 144 : 143; + var otherKind = node.kind === 145 ? 146 : 145; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -18443,9 +18887,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213) { - ts.Debug.assert(signatureDeclarationNode.kind === 145 || signatureDeclarationNode.kind === 146); - var signatureKind = signatureDeclarationNode.kind === 145 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 215) { + ts.Debug.assert(signatureDeclarationNode.kind === 147 || signatureDeclarationNode.kind === 148); + var signatureKind = signatureDeclarationNode.kind === 147 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -18463,7 +18907,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 213 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 215 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -18539,7 +18983,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 141 || node.kind === 140); + ts.Debug.assert(node.kind === 143 || node.kind === 142); 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_1, diagnostic); @@ -18571,11 +19015,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 213 || node.parent.kind === 153 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 215 || node.parent.kind === 155 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 211 || node.kind === 141 || node.kind === 140 || node.kind === 142) { + if (node.kind === 213 || node.kind === 143 || node.kind === 142 || node.kind === 144) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -18688,16 +19132,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 213: + case 215: return 2097152; - case 216: + case 218: return d.name.kind === 9 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 212: - case 215: + case 214: + case 217: return 2097152 | 1048576; - case 219: + case 221: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -18708,7 +19152,8 @@ var ts; } } function checkNonThenableType(type, location, message) { - if (!(type.flags & 1) && isTypeAssignableTo(type, getGlobalThenableType())) { + type = getWidenedType(type); + if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -18823,22 +19268,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 212: + case 214: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 136: + case 138: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 139: + case 141: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 141: case 143: - case 144: + case 145: + case 146: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -18847,9 +19292,9 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 149) { + if (node && node.kind === 151) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 149 ? 793056 : 1536; + var meaning = root.parent.kind === 151 ? 793056 : 1536; var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); if (rootSymbol && rootSymbol.flags & 8388608) { var aliasTarget = resolveAlias(rootSymbol); @@ -18861,19 +19306,19 @@ var ts; } function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 139: + case 141: checkTypeNodeAsExpression(node.type); break; - case 136: + case 138: checkTypeNodeAsExpression(node.type); break; - case 141: + case 143: checkTypeNodeAsExpression(node.type); break; - case 143: + case 145: checkTypeNodeAsExpression(node.type); break; - case 144: + case 146: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -18896,24 +19341,24 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 212: + case 214: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 141: - checkParameterTypeAnnotationsAsExpressions(node); - case 144: case 143: - case 139: - case 136: + checkParameterTypeAnnotationsAsExpressions(node); + case 146: + case 145: + case 141: + case 138: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 136) { + if (node.kind === 138) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -18931,12 +19376,9 @@ var ts; checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { - if (!compilerOptions.experimentalAsyncFunctions) { - error(node, ts.Diagnostics.Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning); - } emitAwaiter = true; } - if (node.name && node.name.kind === 134) { + if (node.name && node.name.kind === 136) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -18971,11 +19413,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 190) { + if (node.kind === 192) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 217) { + if (ts.isFunctionBlock(node) || node.kind === 219) { checkFunctionAndClassExpressionBodies(node); } } @@ -18993,19 +19435,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 139 || - node.kind === 138 || - node.kind === 141 || + if (node.kind === 141 || node.kind === 140 || node.kind === 143 || - node.kind === 144) { + node.kind === 142 || + node.kind === 145 || + node.kind === 146) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 136 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 138 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -19019,7 +19461,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 67; + var isDeclaration_1 = node.kind !== 69; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -19040,7 +19482,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 67; + var isDeclaration_2 = node.kind !== 69; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -19053,11 +19495,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 216 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 218 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 246 && ts.isExternalModule(parent)) { + if (parent.kind === 248 && ts.isExternalOrCommonJsModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -19065,7 +19507,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 209 && !node.initializer) { + if (node.kind === 211 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -19075,15 +19517,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210); - var container = varDeclList.parent.kind === 191 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212); + var container = varDeclList.parent.kind === 193 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 190 && ts.isFunctionLike(container.parent) || - container.kind === 217 || - container.kind === 216 || - container.kind === 246); + (container.kind === 192 && ts.isFunctionLike(container.parent) || + container.kind === 219 || + container.kind === 218 || + container.kind === 248); if (!namesShareScope) { var name_14 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_14, name_14); @@ -19093,16 +19535,16 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 136) { + if (ts.getRootDeclaration(node).kind !== 138) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 67) { + if (n.kind === 69) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 136) { + if (referencedSymbol.valueDeclaration.kind === 138) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -19122,7 +19564,7 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 134) { + if (node.name.kind === 136) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -19131,7 +19573,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 136 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 138 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -19159,9 +19601,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 139 && node.kind !== 138) { + if (node.kind !== 141 && node.kind !== 140) { checkExportsOnMergedDeclarations(node); - if (node.kind === 209 || node.kind === 161) { + if (node.kind === 211 || node.kind === 163) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -19182,7 +19624,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 163) { + if (node.modifiers && node.parent.kind === 165) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -19215,12 +19657,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 210) { + if (node.initializer && node.initializer.kind === 212) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -19235,13 +19677,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 162 || varExpr.kind === 163) { + if (varExpr.kind === 164 || varExpr.kind === 165) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -19256,7 +19698,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { 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); @@ -19266,7 +19708,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 162 || varExpr.kind === 163) { + if (varExpr.kind === 164 || varExpr.kind === 165) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { @@ -19428,7 +19870,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144))); + return !!(node.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -19446,10 +19888,10 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 144) { + if (func.kind === 146) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 142) { + else if (func.kind === 144) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -19458,7 +19900,9 @@ var ts; if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - checkTypeAssignableTo(awaitedType, promisedType, node.expression); + if (promisedType) { + checkTypeAssignableTo(awaitedType, promisedType, node.expression); + } } else { checkTypeAssignableTo(exprType, returnType, node.expression); @@ -19482,7 +19926,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 240 && !hasDuplicateDefaultClause) { + if (clause.kind === 242 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -19494,7 +19938,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 239) { + if (produceDiagnostics && clause.kind === 241) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -19511,7 +19955,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 205 && current.label.text === node.label.text) { + if (current.kind === 207 && 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; @@ -19537,7 +19981,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 67) { + if (catchClause.variableDeclaration.name.kind !== 69) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -19605,7 +20049,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 134 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 136 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -19675,6 +20119,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { @@ -19693,7 +20138,7 @@ var ts; } } } - checkTypeAssignableTo(type, baseType, node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32)) { var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); @@ -19706,7 +20151,8 @@ var ts; } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { - ts.forEach(implementedTypeNodes, function (typeRefNode) { + for (var _b = 0; _b < implementedTypeNodes.length; _b++) { + var typeRefNode = implementedTypeNodes[_b]; if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } @@ -19716,14 +20162,14 @@ var ts; if (t !== unknownType) { var declaredType = (t.flags & 4096) ? t.target : t; if (declaredType.flags & (1024 | 2048)) { - checkTypeAssignableTo(type, t, node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { error(typeRefNode, ts.Diagnostics.A_class_may_only_implement_another_class_or_interface); } } } - }); + } } if (produceDiagnostics) { checkIndexConstraints(type); @@ -19751,7 +20197,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) { - if (derivedClassDecl.kind === 184) { + if (derivedClassDecl.kind === 186) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -19795,7 +20241,7 @@ var ts; } } function isAccessor(kind) { - return kind === 143 || kind === 144; + return kind === 145 || kind === 146; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -19832,7 +20278,7 @@ var ts; var ok = true; for (var _i = 0; _i < baseTypes.length; _i++) { var base = baseTypes[_i]; - var properties = getPropertiesOfObjectType(base); + var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); for (var _a = 0; _a < properties.length; _a++) { var prop = properties[_a]; if (!ts.hasProperty(seen, prop.name)) { @@ -19861,7 +20307,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 215); 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); @@ -19869,17 +20315,19 @@ var ts; } if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); if (checkInheritedPropertiesAreIdentical(type, node.name)) { - ts.forEach(getBaseTypes(type), function (baseType) { - checkTypeAssignableTo(type, baseType, node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); - }); + for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) { + var baseType = _a[_i]; + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); + } checkIndexConstraints(type); } } if (symbol && symbol.declarations) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 212 && !ts.isInAmbientContext(declaration)) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var declaration = _c[_b]; + if (declaration.kind === 214 && !ts.isInAmbientContext(declaration)) { error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } @@ -19910,10 +20358,15 @@ var ts; var autoValue = 0; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); - ts.forEach(node.members, function (member) { - if (member.name.kind !== 134 && isNumericLiteralName(member.name.text)) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.name.kind === 136) { + error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); + } + else if (isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } + var previousEnumMemberIsNonConstant = autoValue === undefined; var initializer = member.initializer; if (initializer) { autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); @@ -19921,10 +20374,13 @@ var ts; else if (ambient && !enumIsConst) { autoValue = undefined; } + else if (previousEnumMemberIsNonConstant) { + error(member.name, ts.Diagnostics.Enum_member_must_have_initializer); + } if (autoValue !== undefined) { getNodeLinks(member).enumMemberValue = autoValue++; } - }); + } nodeLinks.flags |= 8192; } function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { @@ -19935,7 +20391,10 @@ var ts; if (enumIsConst) { error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); } - else if (!ambient) { + else if (ambient) { + error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); + } + else { checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); } } @@ -19951,7 +20410,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 177: + case 179: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -19959,10 +20418,10 @@ var ts; switch (e.operator) { case 35: return value_1; case 36: return -value_1; - case 49: return ~value_1; + case 50: return ~value_1; } return undefined; - case 179: + case 181: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -19972,37 +20431,37 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 46: return left | right; - case 45: return left & right; - case 43: return left >> right; - case 44: return left >>> right; - case 42: return left << right; - case 47: return left ^ right; + case 47: return left | right; + case 46: return left & right; + case 44: return left >> right; + case 45: return left >>> right; + case 43: return left << right; + case 48: return left ^ right; case 37: return left * right; - case 38: return left / right; + case 39: return left / right; case 35: return left + right; case 36: return left - right; - case 39: return left % right; + case 40: return left % right; } return undefined; case 8: return +e.text; - case 170: + case 172: return evalConstant(e.expression); - case 67: - case 165: - case 164: + case 69: + case 167: + case 166: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName; - if (e.kind === 67) { + if (e.kind === 69) { enumType_1 = currentType; propertyName = e.text; } else { var expression; - if (e.kind === 165) { + if (e.kind === 167) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -20016,10 +20475,10 @@ var ts; } var current = expression; while (current) { - if (current.kind === 67) { + if (current.kind === 69) { break; } - else if (current.kind === 164) { + else if (current.kind === 166) { current = current.expression; } else { @@ -20042,7 +20501,7 @@ var ts; if (member === propertyDecl) { return undefined; } - if (!isDefinedBefore(propertyDecl, member)) { + if (!isBlockScopedNameDeclaredBeforeUse(propertyDecl, member)) { reportError = false; error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; @@ -20056,7 +20515,7 @@ var ts; if (!produceDiagnostics) { return; } - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -20078,7 +20537,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 215) { + if (declaration.kind !== 217) { return false; } var enumDeclaration = declaration; @@ -20101,8 +20560,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 212 || - (declaration.kind === 211 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 214 || + (declaration.kind === 213 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -20153,7 +20612,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 212); + var mergedClass = ts.getDeclarationOfKind(symbol, 214); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -20161,9 +20620,9 @@ var ts; } if (isAmbientExternalModule) { if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); } - if (isExternalModuleNameRelative(node.name.text)) { + if (ts.isExternalModuleNameRelative(node.name.text)) { error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); } } @@ -20172,17 +20631,17 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 133) { + if (node.kind === 135) { node = node.left; } - else if (node.kind === 164) { + else if (node.kind === 166) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 67); + ts.Debug.assert(node.kind === 69); return node; } function checkExternalImportOrExportDeclaration(node) { @@ -20191,14 +20650,14 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; - if (node.parent.kind !== 246 && !inAmbientExternalModule) { - error(moduleName, node.kind === 226 ? + var inAmbientExternalModule = node.parent.kind === 219 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 248 && !inAmbientExternalModule) { + error(moduleName, node.kind === 228 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; } - if (inAmbientExternalModule && isExternalModuleNameRelative(moduleName.text)) { + if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); return false; } @@ -20212,7 +20671,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 228 ? + var message = node.kind === 230 ? 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)); @@ -20238,7 +20697,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222) { + if (importClause.namedBindings.kind === 224) { checkImportBinding(importClause.namedBindings); } else { @@ -20273,8 +20732,8 @@ var ts; } } else { - if (languageVersion >= 2 && !ts.isInAmbientContext(node)) { - 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); + if (modulekind === 5 && !ts.isInAmbientContext(node)) { + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } } @@ -20289,8 +20748,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; - if (node.parent.kind !== 246 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 219 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 248 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -20303,7 +20762,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 246 && node.parent.kind !== 217 && node.parent.kind !== 216) { + if (node.parent.kind !== 248 && node.parent.kind !== 219 && node.parent.kind !== 218) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -20317,15 +20776,15 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 246 ? node.parent : node.parent.parent; - if (container.kind === 216 && container.name.kind === 67) { + var container = node.parent.kind === 248 ? node.parent : node.parent.parent; + if (container.kind === 218 && container.name.kind === 69) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 67) { + if (node.expression.kind === 69) { markExportAsReferenced(node); } else { @@ -20333,19 +20792,19 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (languageVersion >= 2) { - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + if (modulekind === 5) { + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); } - else if (compilerOptions.module === 4) { + else if (modulekind === 4) { grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); } } } function getModuleStatements(node) { - if (node.kind === 246) { + if (node.kind === 248) { return node.statements; } - if (node.kind === 216 && node.body.kind === 217) { + if (node.kind === 218 && node.body.kind === 219) { return node.body.statements; } return emptyArray; @@ -20382,183 +20841,182 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 216: - case 212: + case 218: + case 214: + case 215: case 213: - case 211: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 135: + case 137: return checkTypeParameter(node); - case 136: - return checkParameter(node); - case 139: case 138: + return checkParameter(node); + case 141: + case 140: return checkPropertyDeclaration(node); - case 150: - case 151: - case 145: - case 146: - return checkSignatureDeclaration(node); + case 152: + case 153: case 147: + case 148: + return checkSignatureDeclaration(node); + case 149: return checkSignatureDeclaration(node); - case 141: - case 140: - return checkMethodDeclaration(node); - case 142: - return checkConstructorDeclaration(node); case 143: + case 142: + return checkMethodDeclaration(node); case 144: + return checkConstructorDeclaration(node); + case 145: + case 146: return checkAccessorDeclaration(node); - case 149: + case 151: return checkTypeReferenceNode(node); - case 148: + case 150: return checkTypePredicate(node); - case 152: - return checkTypeQuery(node); - case 153: - return checkTypeLiteral(node); case 154: - return checkArrayType(node); + return checkTypeQuery(node); case 155: - return checkTupleType(node); + return checkTypeLiteral(node); case 156: + return checkArrayType(node); case 157: - return checkUnionOrIntersectionType(node); + return checkTupleType(node); case 158: + case 159: + return checkUnionOrIntersectionType(node); + case 160: return checkSourceElement(node.type); - case 211: + case 213: return checkFunctionDeclaration(node); - case 190: - case 217: + case 192: + case 219: return checkBlock(node); - case 191: - return checkVariableStatement(node); case 193: - return checkExpressionStatement(node); - case 194: - return checkIfStatement(node); + return checkVariableStatement(node); case 195: - return checkDoStatement(node); + return checkExpressionStatement(node); case 196: - return checkWhileStatement(node); + return checkIfStatement(node); case 197: - return checkForStatement(node); + return checkDoStatement(node); case 198: - return checkForInStatement(node); + return checkWhileStatement(node); case 199: - return checkForOfStatement(node); + return checkForStatement(node); case 200: + return checkForInStatement(node); case 201: - return checkBreakOrContinueStatement(node); + return checkForOfStatement(node); case 202: - return checkReturnStatement(node); case 203: - return checkWithStatement(node); + return checkBreakOrContinueStatement(node); case 204: - return checkSwitchStatement(node); + return checkReturnStatement(node); case 205: - return checkLabeledStatement(node); + return checkWithStatement(node); case 206: - return checkThrowStatement(node); + return checkSwitchStatement(node); case 207: - return checkTryStatement(node); + return checkLabeledStatement(node); + case 208: + return checkThrowStatement(node); case 209: + return checkTryStatement(node); + case 211: return checkVariableDeclaration(node); - case 161: + case 163: return checkBindingElement(node); - case 212: + case 214: return checkClassDeclaration(node); - case 213: + case 215: return checkInterfaceDeclaration(node); - case 214: + case 216: return checkTypeAliasDeclaration(node); - case 215: + case 217: return checkEnumDeclaration(node); - case 216: + case 218: return checkModuleDeclaration(node); - case 220: + case 222: return checkImportDeclaration(node); - case 219: + case 221: return checkImportEqualsDeclaration(node); - case 226: + case 228: return checkExportDeclaration(node); - case 225: + case 227: return checkExportAssignment(node); - case 192: + case 194: checkGrammarStatementInAmbientContext(node); return; - case 208: + case 210: checkGrammarStatementInAmbientContext(node); return; - case 229: + case 231: return checkMissingDeclaration(node); } } function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 171: - case 172: + case 173: + case 174: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 184: + case 186: ts.forEach(node.members, checkSourceElement); + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; - case 141: - case 140: + case 143: + case 142: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 142: - case 143: case 144: - case 211: + case 145: + case 146: + case 213: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 203: + case 205: checkFunctionAndClassExpressionBodies(node.expression); break; - case 137: - case 136: case 139: case 138: - case 159: - case 160: + case 141: + case 140: case 161: case 162: case 163: - case 243: case 164: case 165: + case 245: case 166: case 167: case 168: - case 181: - case 188: case 169: - case 187: case 170: - case 174: - case 175: + case 183: + case 190: + case 171: + case 189: + case 172: case 176: - case 173: case 177: case 178: + case 175: case 179: case 180: - case 183: + case 181: case 182: - case 190: - case 217: - case 191: + case 185: + case 184: + case 192: + case 219: case 193: - case 194: case 195: case 196: case 197: @@ -20567,29 +21025,31 @@ var ts; case 200: case 201: case 202: + case 203: case 204: - case 218: - case 239: - case 240: - case 205: case 206: - case 207: + case 220: + case 241: case 242: + case 207: + case 208: case 209: - case 210: + case 244: + case 211: case 212: - case 241: - case 186: - case 215: - case 245: - case 225: - case 246: - case 238: - case 231: - case 232: - case 236: - case 237: + case 214: + case 243: + case 188: + case 217: + case 247: + case 227: + case 248: + case 240: case 233: + case 234: + case 238: + case 239: + case 235: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -20612,7 +21072,7 @@ var ts; potentialThisCollisions.length = 0; ts.forEach(node.statements, checkSourceElement); checkFunctionAndClassExpressionBodies(node); - if (ts.isExternalModule(node)) { + if (ts.isExternalOrCommonJsModule(node)) { checkExternalModuleExports(node); } if (potentialThisCollisions.length) { @@ -20667,7 +21127,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 203 && node.parent.statement === node) { + if (node.parent.kind === 205 && node.parent.statement === node) { return true; } node = node.parent; @@ -20689,28 +21149,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 246: - if (!ts.isExternalModule(location)) { + case 248: + if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 216: + case 218: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 215: + case 217: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 184: + case 186: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 212: - case 213: + case 214: + case 215: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 171: + case 173: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -20743,42 +21203,42 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 67 && + return name.kind === 69 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 135: - case 212: - case 213: + case 137: case 214: case 215: + case 216: + case 217: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 133) { + while (node.parent && node.parent.kind === 135) { node = node.parent; } - return node.parent && node.parent.kind === 149; + return node.parent && node.parent.kind === 151; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 164) { + while (node.parent && node.parent.kind === 166) { node = node.parent; } - return node.parent && node.parent.kind === 186; + return node.parent && node.parent.kind === 188; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 133) { + while (nodeOnRightSide.parent.kind === 135) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 219) { + if (nodeOnRightSide.parent.kind === 221) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 225) { + if (nodeOnRightSide.parent.kind === 227) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -20790,10 +21250,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 225) { + if (entityName.parent.kind === 227) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 164) { + if (entityName.kind !== 166) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -20802,31 +21262,40 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 186 ? 793056 : 1536; + var meaning = 0; + if (entityName.parent.kind === 188) { + meaning = 793056; + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + meaning |= 107455; + } + } + else { + meaning = 1536; + } meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 233) || - (entityName.parent.kind === 232) || - (entityName.parent.kind === 235)) { + else if ((entityName.parent.kind === 235) || + (entityName.parent.kind === 234) || + (entityName.parent.kind === 237)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 67) { + if (entityName.kind === 69) { var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 164) { + else if (entityName.kind === 166) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 133) { + else if (entityName.kind === 135) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -20835,14 +21304,14 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 149 ? 793056 : 1536; + var meaning = entityName.parent.kind === 151 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 236) { + else if (entityName.parent.kind === 238) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 148) { + if (entityName.parent.kind === 150) { return resolveEntityName(entityName, 1); } return undefined; @@ -20854,14 +21323,14 @@ var ts; if (ts.isDeclarationName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 67) { + if (node.kind === 69) { if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 225 + return node.parent.kind === 227 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } - else if (node.parent.kind === 161 && - node.parent.parent.kind === 159 && + else if (node.parent.kind === 163 && + node.parent.parent.kind === 161 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -20871,29 +21340,29 @@ var ts; } } switch (node.kind) { - case 67: - case 164: - case 133: + case 69: + case 166: + case 135: return getSymbolOfEntityNameOrPropertyAccessExpression(node); + case 97: case 95: - case 93: - var type = checkExpression(node); + var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 119: + case 121: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 142) { + if (constructorDeclaration && constructorDeclaration.kind === 144) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 220 || node.parent.kind === 226) && + ((node.parent.kind === 222 || node.parent.kind === 228) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 165 && node.parent.argumentExpression === node) { + if (node.parent.kind === 167 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -20907,7 +21376,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 244) { + if (location && location.kind === 246) { return resolveEntityName(location.name, 107455); } return undefined; @@ -21007,11 +21476,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 246) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 248) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 216 || n.kind === 215) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 218 || n.kind === 217) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -21024,11 +21493,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 190: - case 218: - case 197: - case 198: + case 192: + case 220: case 199: + case 200: + case 201: return true; } return false; @@ -21054,22 +21523,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 219: case 221: - case 222: + case 223: case 224: - case 228: - return isAliasResolvedToValue(getSymbolOfNode(node)); case 226: + case 230: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case 228: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 225: - return node.expression && node.expression.kind === 67 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 227: + return node.expression && node.expression.kind === 69 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 246 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 248 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -21117,7 +21586,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 245) { + if (node.kind === 247) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -21203,21 +21672,6 @@ var ts; var symbol = getReferencedValueSymbol(reference); return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; } - function getBlockScopedVariableId(n) { - ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 161 || (n.parent.kind === 209 && 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 !== 242; - if (isLetOrConst) { - getSymbolLinks(symbol); - return symbol.id; - } - return undefined; - } function instantiateSingleCallFunctionType(functionType, typeArguments) { if (functionType === unknownType) { return unknownType; @@ -21249,7 +21703,6 @@ var ts; isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, collectLinkedAliases: collectLinkedAliases, - getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, isOptionalParameter: isOptionalParameter @@ -21260,7 +21713,7 @@ var ts; ts.bindSourceFile(file); }); ts.forEach(host.getSourceFiles(), function (file) { - if (!ts.isExternalModule(file)) { + if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } }); @@ -21288,6 +21741,7 @@ var ts; getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); getGlobalThenableType = ts.memoize(createThenableType); + cjsRequireType = getExportedTypeFromNamespace("CommonJS", "Require"); if (languageVersion >= 2) { globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); @@ -21330,10 +21784,7 @@ var ts; if (!ts.nodeCanBeDecorated(node)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } - else if (languageVersion < 1) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (node.kind === 143 || node.kind === 144) { + else if (node.kind === 145 || node.kind === 146) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -21343,38 +21794,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 143: + case 145: + case 146: case 144: - case 142: - case 139: - case 138: case 141: case 140: - case 147: - case 216: - case 220: - case 219: - case 226: - case 225: - case 136: + case 143: + case 142: + case 149: + case 218: + case 222: + case 221: + case 228: + case 227: + case 138: break; - case 211: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116) && - node.parent.kind !== 217 && node.parent.kind !== 246) { + case 213: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118) && + node.parent.kind !== 219 && node.parent.kind !== 248) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 212: - case 213: - case 191: case 214: - if (node.modifiers && node.parent.kind !== 217 && node.parent.kind !== 246) { + case 215: + case 193: + case 216: + if (node.modifiers && node.parent.kind !== 219 && node.parent.kind !== 248) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 215: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72) && - node.parent.kind !== 217 && node.parent.kind !== 246) { + case 217: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74) && + node.parent.kind !== 219 && node.parent.kind !== 248) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -21389,14 +21840,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { + case 112: + case 111: case 110: - case 109: - case 108: var text = void 0; - if (modifier.kind === 110) { + if (modifier.kind === 112) { text = "public"; } - else if (modifier.kind === 109) { + else if (modifier.kind === 111) { text = "protected"; lastProtected = modifier; } @@ -21413,11 +21864,11 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 217 || node.parent.kind === 246) { + else if (node.parent.kind === 219 || node.parent.kind === 248) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256) { - if (modifier.kind === 108) { + if (modifier.kind === 110) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -21426,17 +21877,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 111: + case 113: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 217 || node.parent.kind === 246) { + else if (node.parent.kind === 219 || node.parent.kind === 248) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256) { @@ -21445,7 +21896,7 @@ var ts; flags |= 128; lastStatic = modifier; break; - case 80: + case 82: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -21458,42 +21909,42 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 214) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 120: + case 122: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 214) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 113: + case 115: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 212) { - if (node.kind !== 141) { + if (node.kind !== 214) { + if (node.kind !== 143) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 212 && node.parent.flags & 256)) { + if (!(node.parent.kind === 214 && node.parent.flags & 256)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128) { @@ -21505,14 +21956,14 @@ var ts; } flags |= 256; break; - case 116: + case 118: if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512; @@ -21520,7 +21971,7 @@ var ts; break; } } - if (node.kind === 142) { + if (node.kind === 144) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -21538,10 +21989,10 @@ var ts; } return; } - else if ((node.kind === 220 || node.kind === 219) && flags & 2) { + else if ((node.kind === 222 || node.kind === 221) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 136 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 138 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512) { @@ -21553,10 +22004,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 141: - case 211: - case 171: - case 172: + case 143: + case 213: + case 173: + case 174: if (!node.asteriskToken) { return false; } @@ -21621,7 +22072,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 172) { + if (node.kind === 174) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -21656,7 +22107,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 !== 128 && parameter.type.kind !== 126) { + if (parameter.type.kind !== 130 && parameter.type.kind !== 128) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -21688,7 +22139,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 185) { + if (arg.kind === 187) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -21715,7 +22166,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 81) { + if (heritageClause.token === 83) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -21728,7 +22179,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 104); + ts.Debug.assert(heritageClause.token === 106); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -21743,14 +22194,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 81) { + if (heritageClause.token === 83) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 104); + ts.Debug.assert(heritageClause.token === 106); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -21759,19 +22210,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 134) { + if (node.kind !== 136) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 179 && computedPropertyName.expression.operatorToken.kind === 24) { + if (computedPropertyName.expression.kind === 181 && computedPropertyName.expression.operatorToken.kind === 24) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 211 || - node.kind === 171 || - node.kind === 141); + ts.Debug.assert(node.kind === 213 || + node.kind === 173 || + node.kind === 143); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -21788,7 +22239,7 @@ var ts; return grammarErrorOnNode(questionToken, message); } } - function checkGrammarObjectLiteralExpression(node) { + function checkGrammarObjectLiteralExpression(node, inDestructuring) { var seen = {}; var Property = 1; var GetAccessor = 2; @@ -21797,26 +22248,29 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_16 = prop.name; - if (prop.kind === 185 || - name_16.kind === 134) { + if (prop.kind === 187 || + name_16.kind === 136) { checkGrammarComputedPropertyName(name_16); continue; } + if (prop.kind === 246 && !inDestructuring && prop.objectAssignmentInitializer) { + return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); + } var currentKind = void 0; - if (prop.kind === 243 || prop.kind === 244) { + if (prop.kind === 245 || prop.kind === 246) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_16.kind === 8) { checkGrammarNumericLiteral(name_16); } currentKind = Property; } - else if (prop.kind === 141) { + else if (prop.kind === 143) { currentKind = Property; } - else if (prop.kind === 143) { + else if (prop.kind === 145) { currentKind = GetAccessor; } - else if (prop.kind === 144) { + else if (prop.kind === 146) { currentKind = SetAccesor; } else { @@ -21848,7 +22302,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 237) { + if (attr.kind === 239) { continue; } var jsxAttr = attr; @@ -21860,7 +22314,7 @@ var ts; return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 238 && !initializer.expression) { + if (initializer && initializer.kind === 240 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -21869,24 +22323,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 210) { + if (forInOrOfStatement.initializer.kind === 212) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 198 + var diagnostic = forInOrOfStatement.kind === 200 ? 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 === 198 + var diagnostic = forInOrOfStatement.kind === 200 ? 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 = forInOrOfStatement.kind === 198 + var diagnostic = forInOrOfStatement.kind === 200 ? 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); @@ -21909,10 +22363,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 143 && accessor.parameters.length) { + else if (kind === 145 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 144) { + else if (kind === 146) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -21937,7 +22391,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 134 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 136 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -21947,7 +22401,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 163) { + if (node.parent.kind === 165) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -21966,22 +22420,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 === 213) { + else if (node.parent.kind === 215) { 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 === 153) { + else if (node.parent.kind === 155) { 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 199: + case 200: + case 201: case 197: case 198: - case 199: - case 195: - case 196: return true; - case 205: + case 207: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -21993,9 +22447,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 205: + case 207: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 200 + var isMisplacedContinueLabel = node.kind === 202 && !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); @@ -22003,8 +22457,8 @@ var ts; return false; } break; - case 204: - if (node.kind === 201 && !node.label) { + case 206: + if (node.kind === 203 && !node.label) { return false; } break; @@ -22017,13 +22471,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 201 + var message = node.kind === 203 ? 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 === 201 + var message = node.kind === 203 ? 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); @@ -22035,7 +22489,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 160 || node.name.kind === 159) { + if (node.name.kind === 162 || node.name.kind === 161) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -22044,7 +22498,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 198 && node.parent.parent.kind !== 199) { + if (node.parent.parent.kind !== 200 && node.parent.parent.kind !== 201) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -22064,7 +22518,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 67) { + if (name.kind === 69) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -22073,7 +22527,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 185) { + if (element.kind !== 187) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -22090,15 +22544,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 194: - case 195: case 196: - case 203: case 197: case 198: + case 205: case 199: + case 200: + case 201: return false; - case 205: + case 207: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -22114,7 +22568,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 177) { + if (expression.kind === 179) { var unaryExpression = expression; if (unaryExpression.operator === 35 || unaryExpression.operator === 36) { expression = unaryExpression.operand; @@ -22125,32 +22579,6 @@ var ts; } return false; } - function checkGrammarEnumDeclaration(enumDecl) { - var enumIsConst = (enumDecl.flags & 32768) !== 0; - var hasError = false; - if (!enumIsConst) { - var inConstantEnumMemberSection = true; - var inAmbientContext = ts.isInAmbientContext(enumDecl); - for (var _i = 0, _a = enumDecl.members; _i < _a.length; _i++) { - var node = _a[_i]; - if (node.name.kind === 134) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); - } - else if (inAmbientContext) { - if (node.initializer && !isIntegerLiteral(node.initializer)) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers) || hasError; - } - } - else if (node.initializer) { - inConstantEnumMemberSection = isIntegerLiteral(node.initializer); - } - else if (!inConstantEnumMemberSection) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Enum_member_must_have_initializer) || hasError; - } - } - } - return hasError; - } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -22176,7 +22604,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 67 && + return node.kind === 69 && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -22196,12 +22624,12 @@ var ts; return true; } } - else if (node.parent.kind === 213) { + else if (node.parent.kind === 215) { 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 === 153) { + else if (node.parent.kind === 155) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -22211,11 +22639,11 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 213 || - node.kind === 220 || - node.kind === 219 || - node.kind === 226 || - node.kind === 225 || + if (node.kind === 215 || + node.kind === 222 || + node.kind === 221 || + node.kind === 228 || + node.kind === 227 || (node.flags & 2) || (node.flags & (1 | 1024))) { return false; @@ -22225,7 +22653,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 191) { + if (ts.isDeclaration(decl) || decl.kind === 193) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -22244,7 +22672,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 === 190 || node.parent.kind === 217 || node.parent.kind === 246) { + if (node.parent.kind === 192 || node.parent.kind === 219 || node.parent.kind === 248) { 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); @@ -22291,6 +22719,7 @@ var ts; var enclosingDeclaration; var currentSourceFile; var reportedDeclarationError = false; + var errorNameNode; var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var moduleElementDeclarationEmitInfo = []; @@ -22316,7 +22745,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 220); + ts.Debug.assert(aliasEmitInfo.node.kind === 222); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -22367,6 +22796,7 @@ var ts; function createAndSetNewTextWriterWithSymbolWriter() { var writer = ts.createTextWriter(newLine); writer.trackSymbol = trackSymbol; + writer.reportInaccessibleThisError = reportInaccessibleThisError; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -22389,10 +22819,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 209) { + if (declaration.kind === 211) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 223 || declaration.kind === 224 || declaration.kind === 221) { + else if (declaration.kind === 225 || declaration.kind === 226 || declaration.kind === 223) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -22403,7 +22833,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 220) { + if (moduleElementEmitInfo.node.kind === 222) { moduleElementEmitInfo.isVisible = true; } else { @@ -22411,12 +22841,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 216) { + if (nodeToCheck.kind === 218) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 216) { + if (nodeToCheck.kind === 218) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -22448,6 +22878,11 @@ var ts; function trackSymbol(symbol, enclosingDeclaration, meaning) { handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); } + function reportInaccessibleThisError() { + if (errorNameNode) { + diagnostics.push(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode))); + } + } function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); @@ -22455,7 +22890,9 @@ var ts; emitType(type); } else { + errorNameNode = declaration.name; resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2, writer); + errorNameNode = undefined; } } function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { @@ -22465,7 +22902,9 @@ var ts; emitType(signature.type); } else { + errorNameNode = signature.name; resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2, writer); + errorNameNode = undefined; } } function emitLines(nodes) { @@ -22503,62 +22942,63 @@ var ts; } function emitType(type) { switch (type.kind) { - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: - case 101: + case 120: + case 131: + case 103: + case 97: case 9: return writeTextOfNode(currentSourceFile, type); - case 186: + case 188: return emitExpressionWithTypeArguments(type); - case 149: + case 151: return emitTypeReference(type); - case 152: - return emitTypeQuery(type); case 154: + return emitTypeQuery(type); + case 156: return emitArrayType(type); - case 155: + case 157: return emitTupleType(type); - case 156: + case 158: return emitUnionType(type); - case 157: + case 159: return emitIntersectionType(type); - case 158: + case 160: return emitParenType(type); - case 150: - case 151: - return emitSignatureDeclarationWithJsDocComments(type); + case 152: case 153: + return emitSignatureDeclarationWithJsDocComments(type); + case 155: return emitTypeLiteral(type); - case 67: + case 69: return emitEntityName(type); - case 133: + case 135: return emitEntityName(type); - case 148: + case 150: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 67) { + if (entityName.kind === 69) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 133 ? entityName.left : entityName.expression; - var right = entityName.kind === 133 ? entityName.right : entityName.name; + var left = entityName.kind === 135 ? entityName.left : entityName.expression; + var right = entityName.kind === 135 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 219 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 221 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 67 || node.expression.kind === 164); + ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 166); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -22634,7 +23074,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 67) { + if (node.expression.kind === 69) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -22652,7 +23092,7 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 67) { + if (node.expression.kind === 69) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } @@ -22670,10 +23110,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 219 || - (node.parent.kind === 246 && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 221 || + (node.parent.kind === 248 && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 248) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -22682,7 +23122,7 @@ var ts; }); } else { - if (node.kind === 220) { + if (node.kind === 222) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -22700,23 +23140,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 211: + case 213: return writeFunctionDeclaration(node); - case 191: + case 193: return writeVariableStatement(node); - case 213: + case 215: return writeInterfaceDeclaration(node); - case 212: - return writeClassDeclaration(node); case 214: + return writeClassDeclaration(node); + case 216: return writeTypeAliasDeclaration(node); - case 215: + case 217: return writeEnumDeclaration(node); - case 216: + case 218: return writeModuleDeclaration(node); - case 219: + case 221: return writeImportEqualsDeclaration(node); - case 220: + case 222: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -22730,7 +23170,7 @@ var ts; if (node.flags & 1024) { write("default "); } - else if (node.kind !== 213) { + else if (node.kind !== 215) { write("declare "); } } @@ -22777,7 +23217,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 222) { + if (namedBindings.kind === 224) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -22803,7 +23243,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 222) { + if (node.importClause.namedBindings.kind === 224) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -22859,7 +23299,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 217) { + while (node.body.kind !== 219) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -22924,7 +23364,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 141 && (node.parent.flags & 32); + return node.parent.kind === 143 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -22934,15 +23374,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 150 || - node.parent.kind === 151 || - (node.parent.parent && node.parent.parent.kind === 153)) { - ts.Debug.assert(node.parent.kind === 141 || - node.parent.kind === 140 || - node.parent.kind === 150 || - node.parent.kind === 151 || - node.parent.kind === 145 || - node.parent.kind === 146); + if (node.parent.kind === 152 || + node.parent.kind === 153 || + (node.parent.parent && node.parent.parent.kind === 155)) { + ts.Debug.assert(node.parent.kind === 143 || + node.parent.kind === 142 || + node.parent.kind === 152 || + node.parent.kind === 153 || + node.parent.kind === 147 || + node.parent.kind === 148); emitType(node.constraint); } else { @@ -22952,31 +23392,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 212: + case 214: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 213: + case 215: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 146: + case 148: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 145: + case 147: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 141: - case 140: + case 143: + case 142: 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 === 212) { + else if (node.parent.parent.kind === 214) { 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 211: + case 213: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -23004,12 +23444,12 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 91) { + else if (!isImplementsList && node.expression.kind === 93) { write("null"); } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 212) { + if (node.parent.parent.kind === 214) { 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; @@ -23089,16 +23529,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 209 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 211 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 139 || node.kind === 138) && ts.hasQuestionToken(node)) { + if ((node.kind === 141 || node.kind === 140) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 139 || node.kind === 138) && node.parent.kind === 153) { + if ((node.kind === 141 || node.kind === 140) && node.parent.kind === 155) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32)) { @@ -23107,14 +23547,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 209) { + if (node.kind === 211) { 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 === 139 || node.kind === 138) { + else if (node.kind === 141 || node.kind === 140) { if (node.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23122,7 +23562,7 @@ var ts; 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 === 212) { + else if (node.parent.kind === 214) { 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 : @@ -23148,7 +23588,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 185) { + if (element.kind !== 187) { elements.push(element); } } @@ -23214,7 +23654,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 143 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 145 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -23227,7 +23667,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 143 + return accessor.kind === 145 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -23236,7 +23676,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 144) { + if (accessorWithTypeAnnotation.kind === 146) { 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 : @@ -23282,17 +23722,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 211) { + if (node.kind === 213) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 141) { + else if (node.kind === 143) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 211) { + if (node.kind === 213) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 142) { + else if (node.kind === 144) { write("constructor"); } else { @@ -23309,11 +23749,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 146 || node.kind === 151) { + if (node.kind === 148 || node.kind === 153) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 147) { + if (node.kind === 149) { write("["); } else { @@ -23322,20 +23762,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 147) { + if (node.kind === 149) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 150 || node.kind === 151; - if (isFunctionTypeOrConstructorType || node.parent.kind === 153) { + var isFunctionTypeOrConstructorType = node.kind === 152 || node.kind === 153; + if (isFunctionTypeOrConstructorType || node.parent.kind === 155) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 142 && !(node.flags & 32)) { + else if (node.kind !== 144 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -23346,23 +23786,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 146: + case 148: 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 145: + case 147: 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 147: + case 149: 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 141: - case 140: + case 143: + case 142: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23370,7 +23810,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 === 212) { + else if (node.parent.kind === 214) { 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 : @@ -23383,7 +23823,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 211: + case 213: 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 : @@ -23415,9 +23855,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 150 || - node.parent.kind === 151 || - node.parent.parent.kind === 153) { + if (node.parent.kind === 152 || + node.parent.kind === 153 || + node.parent.parent.kind === 155) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -23433,22 +23873,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 142: + case 144: return 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; - case 146: + case 148: return 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; - case 145: + case 147: return 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; - case 141: - case 140: + case 143: + case 142: if (node.parent.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23456,7 +23896,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 === 212) { + else if (node.parent.parent.kind === 214) { return 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 : @@ -23468,7 +23908,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 211: + case 213: return 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 : @@ -23479,12 +23919,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 159) { + if (bindingPattern.kind === 161) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 160) { + else if (bindingPattern.kind === 162) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -23503,10 +23943,10 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 185) { + if (bindingElement.kind === 187) { write(" "); } - else if (bindingElement.kind === 161) { + else if (bindingElement.kind === 163) { if (bindingElement.propertyName) { writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); @@ -23516,7 +23956,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 67); + ts.Debug.assert(bindingElement.name.kind === 69); if (bindingElement.dotDotDotToken) { write("..."); } @@ -23528,39 +23968,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 211: - case 216: - case 219: case 213: - case 212: - case 214: + case 218: + case 221: case 215: + case 214: + case 216: + case 217: return emitModuleElement(node, isModuleElementVisible(node)); - case 191: + case 193: return emitModuleElement(node, isVariableStatementVisible(node)); - case 220: + case 222: return emitModuleElement(node, !node.importClause); - case 226: + case 228: return emitExportDeclaration(node); + case 144: + case 143: case 142: - case 141: - case 140: return writeFunctionDeclaration(node); - case 146: - case 145: + case 148: case 147: + case 149: return emitSignatureDeclarationWithJsDocComments(node); - case 143: - case 144: + case 145: + case 146: return emitAccessorDeclaration(node); - case 139: - case 138: + case 141: + case 140: return emitPropertyDeclaration(node); - case 245: + case 247: return emitEnumMemberDeclaration(node); - case 225: + case 227: return emitExportAssignment(node); - case 246: + case 248: return emitSourceFile(node); } } @@ -23603,5471 +24043,6 @@ var ts; return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); } ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; - function emitFiles(resolver, host, targetSourceFile) { - var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; - var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; - var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; - var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; - var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; - var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0; - var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; - var diagnostics = []; - var newLine = host.getNewLine(); - var jsxDesugaring = host.getCompilerOptions().jsx !== 1; - var shouldEmitJsx = function (s) { return (s.languageVariant === 1 && !jsxDesugaring); }; - if (targetSourceFile === undefined) { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); - emitFile(jsFilePath, sourceFile); - } - }); - if (compilerOptions.outFile || compilerOptions.out) { - emitFile(compilerOptions.outFile || compilerOptions.out); - } - } - else { - if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); - emitFile(jsFilePath, targetSourceFile); - } - else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { - emitFile(compilerOptions.outFile || compilerOptions.out); - } - } - diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); - return { - emitSkipped: false, - 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 = ts.createTextWriter(newLine); - var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; - var currentSourceFile; - var exportFunctionForFile; - var generatedNameSet = {}; - var nodeToGeneratedName = []; - var computedPropertyNamesToGeneratedNames; - var extendsEmitted = false; - var decorateEmitted = false; - var paramEmitted = false; - var awaiterEmitted = false; - var tempFlags = 0; - var tempVariables; - var tempParameters; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStars; - var writeEmittedFiles = writeJavaScriptFile; - var detachedCommentsInfo; - var writeComment = ts.writeCommentRange; - var emit = emitNodeWithCommentsAndWithoutSourcemap; - var emitStart = function (node) { }; - var emitEnd = function (node) { }; - var emitToken = emitTokenText; - var scopeEmitStart = function (scopeDeclaration, scopeName) { }; - var scopeEmitEnd = function () { }; - var sourceMapData; - var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; - if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { - initializeEmitterWithSourceMaps(); - } - if (root) { - emitSourceFile(root); - } - else { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { - emitSourceFile(sourceFile); - } - }); - } - writeLine(); - writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); - return; - function emitSourceFile(sourceFile) { - currentSourceFile = sourceFile; - exportFunctionForFile = undefined; - emit(sourceFile); - } - function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentSourceFile.identifiers, name) && - !ts.hasProperty(generatedNameSet, name); - } - function makeTempVariableName(flags) { - if (flags && !(tempFlags & flags)) { - var name_19 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_19)) { - tempFlags |= flags; - return name_19; - } - } - while (true) { - var count = tempFlags & 268435455; - tempFlags++; - if (count !== 8 && count !== 13) { - var name_20 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_20)) { - return name_20; - } - } - } - } - 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 generateNameForModuleOrEnum(node) { - var name = node.name.text; - return isUniqueLocalName(name, node) ? name : makeUniqueName(name); - } - function generateNameForImportOrExportDeclaration(node) { - var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 9 ? - ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - return makeUniqueName(baseName); - } - function generateNameForExportDefault() { - return makeUniqueName("default"); - } - function generateNameForClassExpression() { - return makeUniqueName("class"); - } - function generateNameForNode(node) { - switch (node.kind) { - case 67: - return makeUniqueName(node.text); - case 216: - case 215: - return generateNameForModuleOrEnum(node); - case 220: - case 226: - return generateNameForImportOrExportDeclaration(node); - case 211: - case 212: - case 225: - return generateNameForExportDefault(); - case 184: - return generateNameForClassExpression(); - } - } - function getGeneratedNameForNode(node) { - var id = ts.getNodeId(node); - return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); - } - function initializeEmitterWithSourceMaps() { - var sourceMapDir; - var sourceMapSourceIndex = -1; - var sourceMapNameIndexMap = {}; - var sourceMapNameIndices = []; - function getSourceMapNameIndex() { - return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; - } - var lastRecordedSourceMapSpan; - var lastEncodedSourceMapSpan = { - emittedLine: 1, - emittedColumn: 1, - sourceLine: 1, - sourceColumn: 1, - sourceIndex: 0 - }; - var lastEncodedNameIndex = 0; - function encodeLastRecordedSourceMapSpan() { - if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { - return; - } - var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { - if (sourceMapData.sourceMapMappings) { - sourceMapData.sourceMapMappings += ","; - } - } - else { - for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { - sourceMapData.sourceMapMappings += ";"; - } - prevEncodedEmittedColumn = 1; - } - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); - if (lastRecordedSourceMapSpan.nameIndex >= 0) { - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); - lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; - } - lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); - function base64VLQFormatEncode(inValue) { - function base64FormatEncode(inValue) { - if (inValue < 64) { - return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - } - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - var encodedStr = ""; - do { - var currentDigit = inValue & 31; - inValue = inValue >> 5; - if (inValue > 0) { - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + base64FormatEncode(currentDigit); - } while (inValue > 0); - return encodedStr; - } - } - function recordSourceMapSpan(pos) { - var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); - sourceLinePos.line++; - sourceLinePos.character++; - var emittedLine = writer.getLine(); - var emittedColumn = writer.getColumn(); - if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine !== emittedLine || - lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || - (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && - (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || - (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { - encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = { - emittedLine: emittedLine, - emittedColumn: emittedColumn, - sourceLine: sourceLinePos.line, - sourceColumn: sourceLinePos.character, - nameIndex: getSourceMapNameIndex(), - sourceIndex: sourceMapSourceIndex - }; - } - else { - lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; - lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; - lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; - } - } - function recordEmitNodeStartSpan(node) { - recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); - } - function recordEmitNodeEndSpan(node) { - recordSourceMapSpan(node.end); - } - function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { - var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); - recordSourceMapSpan(tokenStartPos); - var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); - recordSourceMapSpan(tokenEndPos); - return tokenEndPos; - } - function recordNewSourceFileStart(node) { - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true)); - sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; - sourceMapData.inputSourceFileNames.push(node.fileName); - if (compilerOptions.inlineSources) { - if (!sourceMapData.sourceMapSourcesContent) { - sourceMapData.sourceMapSourcesContent = []; - } - sourceMapData.sourceMapSourcesContent.push(node.text); - } - } - function recordScopeNameOfNode(node, scopeName) { - function recordScopeNameIndex(scopeNameIndex) { - sourceMapNameIndices.push(scopeNameIndex); - } - function recordScopeNameStart(scopeName) { - var scopeNameIndex = -1; - if (scopeName) { - var parentIndex = getSourceMapNameIndex(); - if (parentIndex !== -1) { - var name_21 = node.name; - if (!name_21 || name_21.kind !== 134) { - scopeName = "." + scopeName; - } - scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; - } - scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); - if (scopeNameIndex === undefined) { - scopeNameIndex = sourceMapData.sourceMapNames.length; - sourceMapData.sourceMapNames.push(scopeName); - sourceMapNameIndexMap[scopeName] = scopeNameIndex; - } - } - recordScopeNameIndex(scopeNameIndex); - } - if (scopeName) { - recordScopeNameStart(scopeName); - } - else if (node.kind === 211 || - node.kind === 171 || - node.kind === 141 || - node.kind === 140 || - node.kind === 143 || - node.kind === 144 || - node.kind === 216 || - node.kind === 212 || - node.kind === 215) { - if (node.name) { - var name_22 = node.name; - scopeName = name_22.kind === 134 - ? ts.getTextOfNode(name_22) - : node.name.text; - } - recordScopeNameStart(scopeName); - } - else { - recordScopeNameIndex(getSourceMapNameIndex()); - } - } - function recordScopeNameEnd() { - sourceMapNameIndices.pop(); - } - ; - function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { - recordSourceMapSpan(comment.pos); - ts.writeCommentRange(currentSourceFile, writer, comment, newLine); - recordSourceMapSpan(comment.end); - } - function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { - if (typeof JSON !== "undefined") { - var map_1 = { - version: version, - file: file, - sourceRoot: sourceRoot, - sources: sources, - names: names, - mappings: mappings - }; - if (sourcesContent !== undefined) { - map_1.sourcesContent = sourcesContent; - } - return JSON.stringify(map_1); - } - return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; - function serializeStringArray(list) { - var output = ""; - for (var i = 0, n = list.length; i < n; i++) { - if (i) { - output += ","; - } - output += "\"" + ts.escapeString(list[i]) + "\""; - } - return output; - } - } - function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { - encodeLastRecordedSourceMapSpan(); - var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); - sourceMapDataList.push(sourceMapData); - var sourceMapUrl; - if (compilerOptions.inlineSourceMap) { - var base64SourceMapText = ts.convertToBase64(sourceMapText); - sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; - } - else { - ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); - sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; - } - writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); - } - var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); - sourceMapData = { - sourceMapFilePath: jsFilePath + ".map", - jsSourceMappingURL: sourceMapJsFile + ".map", - sourceMapFile: sourceMapJsFile, - sourceMapSourceRoot: compilerOptions.sourceRoot || "", - sourceMapSources: [], - inputSourceFileNames: [], - sourceMapNames: [], - sourceMapMappings: "", - sourceMapSourcesContent: undefined, - sourceMapDecodedMappings: [] - }; - sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); - if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47) { - sourceMapData.sourceMapSourceRoot += ts.directorySeparator; - } - if (compilerOptions.mapRoot) { - sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (root) { - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); - } - if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { - sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), host.getCurrentDirectory(), host.getCanonicalFileName, true); - } - else { - sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); - } - } - else { - sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); - } - function emitNodeWithSourceMap(node) { - if (node) { - if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node); - } - if (node.kind !== 246) { - recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node); - recordEmitNodeEndSpan(node); - } - else { - recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node); - } - } - } - function emitNodeWithCommentsAndWithSourcemap(node) { - emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); - } - writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithCommentsAndWithSourcemap; - emitStart = recordEmitNodeStartSpan; - emitEnd = recordEmitNodeEndSpan; - emitToken = writeTextWithSpanRecord; - scopeEmitStart = recordScopeNameOfNode; - scopeEmitEnd = recordScopeNameEnd; - writeComment = writeCommentRangeWithMap; - } - function writeJavaScriptFile(emitOutput, writeByteOrderMark) { - ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); - } - function createTempVariable(flags) { - var result = ts.createSynthesizedNode(67); - result.text = makeTempVariableName(flags); - return result; - } - function recordTempDeclaration(name) { - if (!tempVariables) { - tempVariables = []; - } - tempVariables.push(name); - } - function createAndRecordTempVariable(flags) { - var temp = createTempVariable(flags); - recordTempDeclaration(temp); - return temp; - } - function emitTempDeclarations(newLine) { - if (tempVariables) { - if (newLine) { - writeLine(); - } - else { - write(" "); - } - write("var "); - emitCommaList(tempVariables); - write(";"); - } - } - function emitTokenText(tokenKind, startPos, emitFn) { - var tokenString = ts.tokenToString(tokenKind); - if (emitFn) { - emitFn(); - } - else { - write(tokenString); - } - return startPos + tokenString.length; - } - function emitOptional(prefix, node) { - if (node) { - write(prefix); - emit(node); - } - } - function emitParenthesizedIf(node, parenthesized) { - if (parenthesized) { - write("("); - } - emit(node); - if (parenthesized) { - write(")"); - } - } - function emitTrailingCommaIfPresent(nodeList) { - if (nodeList.hasTrailingComma) { - write(","); - } - } - function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { - ts.Debug.assert(nodes.length > 0); - increaseIndent(); - if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - for (var i = 0, n = nodes.length; i < n; i++) { - if (i) { - if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { - write(", "); - } - else { - write(","); - writeLine(); - } - } - emit(nodes[i]); - } - if (nodes.hasTrailingComma && allowTrailingComma) { - write(","); - } - decreaseIndent(); - if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - } - function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { - if (!emitNode) { - emitNode = emit; - } - for (var i = 0; i < count; i++) { - if (multiLine) { - if (i || leadingComma) { - write(","); - } - writeLine(); - } - else { - if (i || leadingComma) { - write(", "); - } - } - var node = nodes[start + i]; - emitTrailingCommentsOfPosition(node.pos); - emitNode(node); - leadingComma = true; - } - if (trailingComma) { - write(","); - } - if (multiLine && !noTrailingNewLine) { - writeLine(); - } - return count; - } - function emitCommaList(nodes) { - if (nodes) { - emitList(nodes, 0, nodes.length, false, false); - } - } - function emitLines(nodes) { - emitLinesStartingAt(nodes, 0); - } - function emitLinesStartingAt(nodes, startIndex) { - for (var i = startIndex; i < nodes.length; i++) { - writeLine(); - emit(nodes[i]); - } - } - function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 && text.length > 1) { - switch (text.charCodeAt(1)) { - case 98: - case 66: - case 111: - case 79: - return true; - } - } - return false; - } - function emitLiteral(node) { - var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { - writer.writeLiteral(text); - } - else if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { - write(node.text); - } - else { - write(text); - } - } - function getLiteralText(node) { - if (languageVersion < 2 && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText("\"", node.text, "\""); - } - if (node.parent) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - } - switch (node.kind) { - case 9: - return getQuotedEscapedLiteralText("\"", node.text, "\""); - case 11: - return getQuotedEscapedLiteralText("`", node.text, "`"); - case 12: - return getQuotedEscapedLiteralText("`", node.text, "${"); - case 13: - return getQuotedEscapedLiteralText("}", node.text, "${"); - case 14: - return getQuotedEscapedLiteralText("}", node.text, "`"); - case 8: - return node.text; - } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); - } - function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { - return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; - } - function emitDownlevelRawTemplateLiteral(node) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 11 || node.kind === 14; - text = text.substring(1, text.length - (isLast ? 1 : 2)); - text = text.replace(/\r\n?/g, "\n"); - text = ts.escapeString(text); - write("\"" + text + "\""); - } - function emitDownlevelTaggedTemplateArray(node, literalEmitter) { - write("["); - if (node.template.kind === 11) { - literalEmitter(node.template); - } - else { - literalEmitter(node.template.head); - ts.forEach(node.template.templateSpans, function (child) { - write(", "); - literalEmitter(child.literal); - }); - } - write("]"); - } - function emitDownlevelTaggedTemplate(node) { - var tempVariable = createAndRecordTempVariable(0); - write("("); - emit(tempVariable); - write(" = "); - emitDownlevelTaggedTemplateArray(node, emit); - write(", "); - emit(tempVariable); - write(".raw = "); - emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); - write(", "); - emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); - write("("); - emit(tempVariable); - if (node.template.kind === 181) { - ts.forEach(node.template.templateSpans, function (templateSpan) { - write(", "); - var needsParens = templateSpan.expression.kind === 179 - && templateSpan.expression.operatorToken.kind === 24; - emitParenthesizedIf(templateSpan.expression, needsParens); - }); - } - write("))"); - } - function emitTemplateExpression(node) { - if (languageVersion >= 2) { - ts.forEachChild(node, emit); - return; - } - var emitOuterParens = ts.isExpression(node.parent) - && templateNeedsParens(node, node.parent); - if (emitOuterParens) { - write("("); - } - var headEmitted = false; - if (shouldEmitTemplateHead()) { - emitLiteral(node.head); - headEmitted = true; - } - for (var i = 0, n = node.templateSpans.length; i < n; i++) { - var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 170 - && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; - if (i > 0 || headEmitted) { - write(" + "); - } - emitParenthesizedIf(templateSpan.expression, needsParens); - if (templateSpan.literal.text.length !== 0) { - write(" + "); - emitLiteral(templateSpan.literal); - } - } - if (emitOuterParens) { - write(")"); - } - function shouldEmitTemplateHead() { - 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 166: - case 167: - return parent.expression === template; - case 168: - case 170: - return false; - default: - return comparePrecedenceToBinaryPlus(parent) !== -1; - } - } - function comparePrecedenceToBinaryPlus(expression) { - switch (expression.kind) { - case 179: - switch (expression.operatorToken.kind) { - case 37: - case 38: - case 39: - return 1; - case 35: - case 36: - return 0; - default: - return -1; - } - case 182: - case 180: - return -1; - default: - return 1; - } - } - } - function emitTemplateSpan(span) { - emit(span.expression); - emit(span.literal); - } - function jsxEmitReact(node) { - function emitTagName(name) { - if (name.kind === 67 && ts.isIntrinsicJsxName(name.text)) { - write("\""); - emit(name); - write("\""); - } - else { - emit(name); - } - } - function emitAttributeName(name) { - if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write("\""); - emit(name); - write("\""); - } - else { - emit(name); - } - } - function emitJsxAttribute(node) { - emitAttributeName(node.name); - write(": "); - if (node.initializer) { - emit(node.initializer); - } - else { - write("true"); - } - } - function emitJsxElement(openingNode, children) { - var syntheticReactRef = ts.createSynthesizedNode(67); - syntheticReactRef.text = 'React'; - syntheticReactRef.parent = openingNode; - emitLeadingComments(openingNode); - emitExpressionIdentifier(syntheticReactRef); - write(".createElement("); - emitTagName(openingNode.tagName); - write(", "); - if (openingNode.attributes.length === 0) { - write("null"); - } - else { - var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 237; })) { - emitExpressionIdentifier(syntheticReactRef); - write(".__spread("); - var haveOpenedObjectLiteral = false; - for (var i_1 = 0; i_1 < attrs.length; i_1++) { - if (attrs[i_1].kind === 237) { - if (i_1 === 0) { - write("{}, "); - } - if (haveOpenedObjectLiteral) { - write("}"); - haveOpenedObjectLiteral = false; - } - if (i_1 > 0) { - write(", "); - } - emit(attrs[i_1].expression); - } - else { - ts.Debug.assert(attrs[i_1].kind === 236); - if (haveOpenedObjectLiteral) { - write(", "); - } - else { - haveOpenedObjectLiteral = true; - if (i_1 > 0) { - write(", "); - } - write("{"); - } - emitJsxAttribute(attrs[i_1]); - } - } - if (haveOpenedObjectLiteral) - write("}"); - write(")"); - } - else { - write("{"); - for (var i = 0; i < attrs.length; i++) { - if (i > 0) { - write(", "); - } - emitJsxAttribute(attrs[i]); - } - write("}"); - } - } - if (children) { - for (var i = 0; i < children.length; i++) { - if (children[i].kind === 238 && !(children[i].expression)) { - continue; - } - if (children[i].kind === 234) { - var text = getTextToEmit(children[i]); - if (text !== undefined) { - write(", \""); - write(text); - write("\""); - } - } - else { - write(", "); - emit(children[i]); - } - } - } - write(")"); - emitTrailingComments(openingNode); - } - if (node.kind === 231) { - emitJsxElement(node.openingElement, node.children); - } - else { - ts.Debug.assert(node.kind === 232); - emitJsxElement(node); - } - } - function jsxEmitPreserve(node) { - function emitJsxAttribute(node) { - emit(node.name); - if (node.initializer) { - write("="); - emit(node.initializer); - } - } - function emitJsxSpreadAttribute(node) { - write("{..."); - emit(node.expression); - write("}"); - } - function emitAttributes(attribs) { - for (var i = 0, n = attribs.length; i < n; i++) { - if (i > 0) { - write(" "); - } - if (attribs[i].kind === 237) { - emitJsxSpreadAttribute(attribs[i]); - } - else { - ts.Debug.assert(attribs[i].kind === 236); - emitJsxAttribute(attribs[i]); - } - } - } - function emitJsxOpeningOrSelfClosingElement(node) { - write("<"); - emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 232)) { - write(" "); - } - emitAttributes(node.attributes); - if (node.kind === 232) { - write("/>"); - } - else { - write(">"); - } - } - function emitJsxClosingElement(node) { - write(""); - } - function emitJsxElement(node) { - emitJsxOpeningOrSelfClosingElement(node.openingElement); - for (var i = 0, n = node.children.length; i < n; i++) { - emit(node.children[i]); - } - emitJsxClosingElement(node.closingElement); - } - if (node.kind === 231) { - emitJsxElement(node); - } - else { - ts.Debug.assert(node.kind === 232); - emitJsxOpeningOrSelfClosingElement(node); - } - } - function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 161); - if (node.kind === 9) { - emitLiteral(node); - } - else if (node.kind === 134) { - if (ts.nodeIsDecorated(node.parent)) { - if (!computedPropertyNamesToGeneratedNames) { - computedPropertyNamesToGeneratedNames = []; - } - var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; - if (generatedName) { - write(generatedName); - return; - } - generatedName = createAndRecordTempVariable(0).text; - computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; - write(generatedName); - write(" = "); - } - emit(node.expression); - } - else { - write("\""); - if (node.kind === 8) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - write("\""); - } - } - function isExpressionIdentifier(node) { - var parent = node.parent; - switch (parent.kind) { - case 162: - case 179: - case 166: - case 239: - case 134: - case 180: - case 137: - case 173: - case 195: - case 165: - case 225: - case 193: - case 186: - case 197: - case 198: - case 199: - case 194: - case 232: - case 233: - case 237: - case 238: - case 167: - case 170: - case 178: - case 177: - case 202: - case 244: - case 183: - case 204: - case 168: - case 188: - case 206: - case 169: - case 174: - case 175: - case 196: - case 203: - case 182: - return true; - case 161: - case 245: - case 136: - case 243: - case 139: - case 209: - return parent.initializer === node; - case 164: - return parent.expression === node; - case 172: - case 171: - return parent.body === node; - case 219: - return parent.moduleReference === node; - case 133: - return parent.left === node; - } - return false; - } - function emitExpressionIdentifier(node) { - if (resolver.getNodeCheckFlags(node) & 2048) { - write("_arguments"); - return; - } - var container = resolver.getReferencedExportContainer(node); - if (container) { - if (container.kind === 246) { - if (languageVersion < 2 && compilerOptions.module !== 4) { - write("exports."); - } - } - else { - write(getGeneratedNameForNode(container)); - write("."); - } - } - else if (languageVersion < 2) { - var declaration = resolver.getReferencedImportDeclaration(node); - if (declaration) { - if (declaration.kind === 221) { - write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 ? "[\"default\"]" : ".default"); - return; - } - else if (declaration.kind === 224) { - write(getGeneratedNameForNode(declaration.parent.parent.parent)); - var name = declaration.propertyName || declaration.name; - var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name); - if (languageVersion === 0 && identifier === "default") { - write("[\"default\"]"); - } - else { - write("."); - write(identifier); - } - return; - } - } - declaration = resolver.getReferencedNestedRedeclaration(node); - if (declaration) { - write(getGeneratedNameForNode(declaration.name)); - return; - } - } - if (ts.nodeIsSynthesized(node)) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function isNameOfNestedRedeclaration(node) { - if (languageVersion < 2) { - var parent_6 = node.parent; - switch (parent_6.kind) { - case 161: - case 212: - case 215: - case 209: - return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); - } - } - return false; - } - function emitIdentifier(node) { - if (!node.parent) { - write(node.text); - } - else if (isExpressionIdentifier(node)) { - emitExpressionIdentifier(node); - } - else if (isNameOfNestedRedeclaration(node)) { - write(getGeneratedNameForNode(node)); - } - else if (ts.nodeIsSynthesized(node)) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function emitThis(node) { - if (resolver.getNodeCheckFlags(node) & 2) { - write("_this"); - } - else { - write("this"); - } - } - function emitSuper(node) { - if (languageVersion >= 2) { - write("super"); - } - else { - var flags = resolver.getNodeCheckFlags(node); - if (flags & 256) { - write("_super.prototype"); - } - else { - write("_super"); - } - } - } - function emitObjectBindingPattern(node) { - write("{ "); - var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); - write(" }"); - } - function emitArrayBindingPattern(node) { - write("["); - var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); - write("]"); - } - function emitBindingElement(node) { - if (node.propertyName) { - emit(node.propertyName); - write(": "); - } - if (node.dotDotDotToken) { - write("..."); - } - if (ts.isBindingPattern(node.name)) { - emit(node.name); - } - else { - emitModuleMemberName(node); - } - emitOptional(" = ", node.initializer); - } - function emitSpreadElementExpression(node) { - write("..."); - emit(node.expression); - } - function emitYieldExpression(node) { - write(ts.tokenToString(112)); - if (node.asteriskToken) { - write("*"); - } - if (node.expression) { - write(" "); - emit(node.expression); - } - } - function emitAwaitExpression(node) { - var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); - if (needsParenthesis) { - write("("); - } - write(ts.tokenToString(112)); - write(" "); - emit(node.expression); - if (needsParenthesis) { - write(")"); - } - } - function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 179 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { - return true; - } - else if (node.parent.kind === 180 && node.parent.condition === node) { - return true; - } - return false; - } - function needsParenthesisForPropertyAccessOrInvocation(node) { - switch (node.kind) { - case 67: - case 162: - case 164: - case 165: - case 166: - case 170: - return false; - } - return true; - } - function emitListWithSpread(elements, needsUniqueCopy, multiLine, trailingComma, useConcat) { - var pos = 0; - var group = 0; - var length = elements.length; - while (pos < length) { - if (group === 1 && useConcat) { - write(".concat("); - } - else if (group > 0) { - write(", "); - } - var e = elements[pos]; - if (e.kind === 183) { - e = e.expression; - emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); - pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162) { - write(".slice()"); - } - } - else { - var i = pos; - while (i < length && elements[i].kind !== 183) { - i++; - } - write("["); - if (multiLine) { - increaseIndent(); - } - emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); - if (multiLine) { - decreaseIndent(); - } - write("]"); - pos = i; - } - group++; - } - if (group > 1) { - if (useConcat) { - write(")"); - } - } - } - function isSpreadElementExpression(node) { - return node.kind === 183; - } - function emitArrayLiteral(node) { - var elements = node.elements; - if (elements.length === 0) { - write("[]"); - } - else if (languageVersion >= 2 || !ts.forEach(elements, isSpreadElementExpression)) { - write("["); - emitLinePreservingList(node, node.elements, elements.hasTrailingComma, false); - write("]"); - } - else { - emitListWithSpread(elements, true, (node.flags & 2048) !== 0, elements.hasTrailingComma, true); - } - } - function emitObjectLiteralBody(node, numElements) { - if (numElements === 0) { - write("{}"); - return; - } - write("{"); - if (numElements > 0) { - var properties = node.properties; - if (numElements === properties.length) { - emitLinePreservingList(node, properties, languageVersion >= 1, true); - } - else { - var multiLine = (node.flags & 2048) !== 0; - if (!multiLine) { - write(" "); - } - else { - increaseIndent(); - } - emitList(properties, 0, numElements, multiLine, false); - if (!multiLine) { - write(" "); - } - else { - decreaseIndent(); - } - } - } - write("}"); - } - function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 2048) !== 0; - var properties = node.properties; - write("("); - if (multiLine) { - increaseIndent(); - } - var tempVar = createAndRecordTempVariable(0); - emit(tempVar); - write(" = "); - emitObjectLiteralBody(node, firstComputedPropertyIndex); - for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { - writeComma(); - var property = properties[i]; - emitStart(property); - if (property.kind === 143 || property.kind === 144) { - var accessors = ts.getAllAccessorDeclarations(node.properties, property); - if (property !== accessors.firstAccessor) { - continue; - } - write("Object.defineProperty("); - emit(tempVar); - write(", "); - emitStart(node.name); - emitExpressionForPropertyName(property.name); - emitEnd(property.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("})"); - emitEnd(property); - } - else { - emitLeadingComments(property); - emitStart(property.name); - emit(tempVar); - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - if (property.kind === 243) { - emit(property.initializer); - } - else if (property.kind === 244) { - emitExpressionIdentifier(property.name); - } - else if (property.kind === 141) { - emitFunctionDeclaration(property); - } - else { - ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); - } - } - emitEnd(property); - } - writeComma(); - emit(tempVar); - if (multiLine) { - decreaseIndent(); - writeLine(); - } - write(")"); - function writeComma() { - if (multiLine) { - write(","); - writeLine(); - } - else { - write(", "); - } - } - } - function emitObjectLiteral(node) { - var properties = node.properties; - if (languageVersion < 2) { - var numProperties = properties.length; - var numInitialNonComputedProperties = numProperties; - for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 134) { - numInitialNonComputedProperties = i; - break; - } - } - var hasComputedProperty = numInitialNonComputedProperties !== properties.length; - if (hasComputedProperty) { - emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); - return; - } - } - emitObjectLiteralBody(node, properties.length); - } - function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(179, startsOnNewLine); - result.operatorToken = ts.createSynthesizedNode(operator); - result.left = left; - result.right = right; - return result; - } - function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(164); - result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(21); - result.name = name; - return result; - } - function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(165); - result.expression = parenthesizeForAccess(expression); - result.argumentExpression = argumentExpression; - return result; - } - function parenthesizeForAccess(expr) { - while (expr.kind === 169 || expr.kind === 187) { - expr = expr.expression; - } - if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 167 && - expr.kind !== 8) { - return expr; - } - var node = ts.createSynthesizedNode(170); - node.expression = expr; - return node; - } - function emitComputedPropertyName(node) { - write("["); - emitExpressionForPropertyName(node); - write("]"); - } - function emitMethod(node) { - if (languageVersion >= 2 && node.asteriskToken) { - write("*"); - } - emit(node.name); - if (languageVersion < 2) { - write(": function "); - } - emitSignatureAndBody(node); - } - function emitPropertyAssignment(node) { - emit(node.name); - write(": "); - emitTrailingCommentsOfPosition(node.initializer.pos); - emit(node.initializer); - } - function isNamespaceExportReference(node) { - var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 246; - } - function emitShorthandPropertyAssignment(node) { - writeTextOfNode(currentSourceFile, node.name); - if (languageVersion < 2 || isNamespaceExportReference(node.name)) { - write(": "); - emit(node.name); - } - } - function tryEmitConstantValue(node) { - var constantValue = tryGetConstEnumValue(node); - if (constantValue !== undefined) { - write(constantValue.toString()); - if (!compilerOptions.removeComments) { - var propertyName = node.kind === 164 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); - write(" /* " + propertyName + " */"); - } - return true; - } - return false; - } - function tryGetConstEnumValue(node) { - if (compilerOptions.isolatedModules) { - return undefined; - } - return node.kind === 164 || node.kind === 165 - ? resolver.getConstantValue(node) - : undefined; - } - function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { - var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); - var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); - if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { - increaseIndent(); - writeLine(); - return true; - } - else { - if (valueToWriteWhenNotIndenting) { - write(valueToWriteWhenNotIndenting); - } - return false; - } - } - function emitPropertyAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); - var shouldEmitSpace; - if (!indentedBeforeDot) { - if (node.expression.kind === 8) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(21)) < 0; - } - else { - var constantValue = tryGetConstEnumValue(node.expression); - shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; - } - } - if (shouldEmitSpace) { - write(" ."); - } - else { - write("."); - } - var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name); - decreaseIndentIf(indentedBeforeDot, indentedAfterDot); - } - function emitQualifiedName(node) { - emit(node.left); - write("."); - emit(node.right); - } - function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 67) { - emitEntityNameAsExpression(node.left, useFallback); - } - else if (useFallback) { - var temp = createAndRecordTempVariable(0); - write("("); - emitNodeWithoutSourceMap(temp); - write(" = "); - emitEntityNameAsExpression(node.left, true); - write(") && "); - emitNodeWithoutSourceMap(temp); - } - else { - emitEntityNameAsExpression(node.left, false); - } - write("."); - emit(node.right); - } - function emitEntityNameAsExpression(node, useFallback) { - switch (node.kind) { - case 67: - if (useFallback) { - write("typeof "); - emitExpressionIdentifier(node); - write(" !== 'undefined' && "); - } - emitExpressionIdentifier(node); - break; - case 133: - emitQualifiedNameAsExpression(node, useFallback); - break; - } - } - function emitIndexedAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - write("["); - emit(node.argumentExpression); - write("]"); - } - function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 183; }); - } - function skipParentheses(node) { - while (node.kind === 170 || node.kind === 169 || node.kind === 187) { - node = node.expression; - } - return node; - } - function emitCallTarget(node) { - if (node.kind === 67 || node.kind === 95 || node.kind === 93) { - emit(node); - return node; - } - var temp = createAndRecordTempVariable(0); - write("("); - emit(temp); - write(" = "); - emit(node); - write(")"); - return temp; - } - function emitCallWithSpread(node) { - var target; - var expr = skipParentheses(node.expression); - if (expr.kind === 164) { - target = emitCallTarget(expr.expression); - write("."); - emit(expr.name); - } - else if (expr.kind === 165) { - target = emitCallTarget(expr.expression); - write("["); - emit(expr.argumentExpression); - write("]"); - } - else if (expr.kind === 93) { - target = expr; - write("_super"); - } - else { - emit(node.expression); - } - write(".apply("); - if (target) { - if (target.kind === 93) { - emitThis(target); - } - else { - emit(target); - } - } - else { - write("void 0"); - } - write(", "); - emitListWithSpread(node.arguments, false, false, false, true); - write(")"); - } - function emitCallExpression(node) { - if (languageVersion < 2 && hasSpreadElement(node.arguments)) { - emitCallWithSpread(node); - return; - } - var superCall = false; - if (node.expression.kind === 93) { - emitSuper(node.expression); - superCall = true; - } - else { - emit(node.expression); - superCall = node.expression.kind === 164 && node.expression.expression.kind === 93; - } - if (superCall && languageVersion < 2) { - write(".call("); - emitThis(node.expression); - if (node.arguments.length) { - write(", "); - emitCommaList(node.arguments); - } - write(")"); - } - else { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - function emitNewExpression(node) { - write("new "); - if (languageVersion === 1 && - node.arguments && - hasSpreadElement(node.arguments)) { - write("("); - var target = emitCallTarget(node.expression); - write(".bind.apply("); - emit(target); - write(", [void 0].concat("); - emitListWithSpread(node.arguments, false, false, false, false); - write(")))"); - write("()"); - } - else { - emit(node.expression); - if (node.arguments) { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - } - function emitTaggedTemplateExpression(node) { - if (languageVersion >= 2) { - emit(node.tag); - write(" "); - emit(node.template); - } - else { - emitDownlevelTaggedTemplate(node); - } - } - function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172) { - if (node.expression.kind === 169 || node.expression.kind === 187) { - var operand = node.expression.expression; - while (operand.kind === 169 || operand.kind === 187) { - operand = operand.expression; - } - if (operand.kind !== 177 && - operand.kind !== 175 && - operand.kind !== 174 && - operand.kind !== 173 && - operand.kind !== 178 && - operand.kind !== 167 && - !(operand.kind === 166 && node.parent.kind === 167) && - !(operand.kind === 171 && node.parent.kind === 166) && - !(operand.kind === 8 && node.parent.kind === 164)) { - emit(operand); - return; - } - } - } - write("("); - emit(node.expression); - write(")"); - } - function emitDeleteExpression(node) { - write(ts.tokenToString(76)); - write(" "); - emit(node.expression); - } - function emitVoidExpression(node) { - write(ts.tokenToString(101)); - write(" "); - emit(node.expression); - } - function emitTypeOfExpression(node) { - write(ts.tokenToString(99)); - write(" "); - emit(node.expression); - } - function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 67 || ts.nodeIsSynthesized(node)) { - return false; - } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 || node.parent.kind === 161); - var targetDeclaration = isVariableDeclarationOrBindingElement - ? node.parent - : resolver.getReferencedValueDeclaration(node); - return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); - } - function emitPrefixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - } - write(ts.tokenToString(node.operator)); - if (node.operand.kind === 177) { - var operand = node.operand; - if (node.operator === 35 && (operand.operator === 35 || operand.operator === 40)) { - write(" "); - } - else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 41)) { - write(" "); - } - } - emit(node.operand); - if (exportChanged) { - write(")"); - } - } - function emitPostfixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - write("(" + exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - write(ts.tokenToString(node.operator)); - emit(node.operand); - if (node.operator === 40) { - write(") - 1)"); - } - else { - write(") + 1)"); - } - } - else { - emit(node.operand); - write(ts.tokenToString(node.operator)); - } - } - function shouldHoistDeclarationInSystemJsModule(node) { - return isSourceFileLevelDeclarationInSystemJsModule(node, false); - } - function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { - if (!node || languageVersion >= 2 || !isCurrentFileSystemExternalModule()) { - return false; - } - var current = node; - while (current) { - if (current.kind === 246) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); - } - else if (ts.isFunctionLike(current) || current.kind === 217) { - return false; - } - else { - current = current.parent; - } - } - } - function emitBinaryExpression(node) { - if (languageVersion < 2 && node.operatorToken.kind === 55 && - (node.left.kind === 163 || node.left.kind === 162)) { - emitDestructuring(node, node.parent.kind === 193); - } - else { - var exportChanged = node.operatorToken.kind >= 55 && - node.operatorToken.kind <= 66 && - isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.left); - write("\", "); - } - emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); - write(ts.tokenToString(node.operatorToken.kind)); - var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); - emit(node.right); - decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); - if (exportChanged) { - write(")"); - } - } - } - function synthesizedNodeStartsOnNewLine(node) { - return ts.nodeIsSynthesized(node) && node.startsOnNewLine; - } - function emitConditionalExpression(node) { - emit(node.condition); - var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); - write("?"); - var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); - emit(node.whenTrue); - decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); - var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); - write(":"); - var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); - emit(node.whenFalse); - decreaseIndentIf(indentedBeforeColon, indentedAfterColon); - } - function decreaseIndentIf(value1, value2) { - if (value1) { - decreaseIndent(); - } - if (value2) { - decreaseIndent(); - } - } - function isSingleLineEmptyBlock(node) { - if (node && node.kind === 190) { - var block = node; - return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); - } - } - function emitBlock(node) { - if (isSingleLineEmptyBlock(node)) { - emitToken(15, node.pos); - write(" "); - emitToken(16, node.statements.end); - return; - } - emitToken(15, node.pos); - increaseIndent(); - scopeEmitStart(node.parent); - if (node.kind === 217) { - ts.Debug.assert(node.parent.kind === 216); - emitCaptureThisForNodeIfNecessary(node.parent); - } - emitLines(node.statements); - if (node.kind === 217) { - emitTempDeclarations(true); - } - decreaseIndent(); - writeLine(); - emitToken(16, node.statements.end); - scopeEmitEnd(); - } - function emitEmbeddedStatement(node) { - if (node.kind === 190) { - write(" "); - emit(node); - } - else { - increaseIndent(); - writeLine(); - emit(node); - decreaseIndent(); - } - } - function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 172); - write(";"); - } - function emitIfStatement(node) { - var endPos = emitToken(86, node.pos); - write(" "); - endPos = emitToken(17, endPos); - emit(node.expression); - emitToken(18, node.expression.end); - emitEmbeddedStatement(node.thenStatement); - if (node.elseStatement) { - writeLine(); - emitToken(78, node.thenStatement.end); - if (node.elseStatement.kind === 194) { - write(" "); - emit(node.elseStatement); - } - else { - emitEmbeddedStatement(node.elseStatement); - } - } - } - function emitDoStatement(node) { - write("do"); - emitEmbeddedStatement(node.statement); - if (node.statement.kind === 190) { - write(" "); - } - else { - writeLine(); - } - write("while ("); - emit(node.expression); - write(");"); - } - function emitWhileStatement(node) { - write("while ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - function tryEmitStartOfVariableDeclarationList(decl, startPos) { - if (shouldHoistVariable(decl, true)) { - return false; - } - var tokenKind = 100; - if (decl && languageVersion >= 2) { - if (ts.isLet(decl)) { - tokenKind = 106; - } - else if (ts.isConst(decl)) { - tokenKind = 72; - } - } - if (startPos !== undefined) { - emitToken(tokenKind, startPos); - write(" "); - } - else { - switch (tokenKind) { - case 100: - write("var "); - break; - case 106: - write("let "); - break; - case 72: - write("const "); - break; - } - } - return true; - } - function emitVariableDeclarationListSkippingUninitializedEntries(list) { - var started = false; - for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { - var decl = _b[_a]; - if (!decl.initializer) { - continue; - } - if (!started) { - started = true; - } - else { - write(", "); - } - emit(decl); - } - return started; - } - function emitForStatement(node) { - var endPos = emitToken(84, node.pos); - write(" "); - endPos = emitToken(17, endPos); - if (node.initializer && node.initializer.kind === 210) { - var variableDeclarationList = node.initializer; - var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - if (startIsEmitted) { - emitCommaList(variableDeclarationList.declarations); - } - else { - emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); - } - } - else if (node.initializer) { - emit(node.initializer); - } - write(";"); - emitOptional(" ", node.condition); - write(";"); - emitOptional(" ", node.incrementor); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 199) { - return emitDownLevelForOfStatement(node); - } - var endPos = emitToken(84, node.pos); - write(" "); - endPos = emitToken(17, endPos); - if (node.initializer.kind === 210) { - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length >= 1) { - tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - emit(variableDeclarationList.declarations[0]); - } - } - else { - emit(node.initializer); - } - if (node.kind === 198) { - write(" in "); - } - else { - write(" of "); - } - emit(node.expression); - emitToken(18, node.expression.end); - emitEmbeddedStatement(node.statement); - } - function emitDownLevelForOfStatement(node) { - var endPos = emitToken(84, node.pos); - write(" "); - endPos = emitToken(17, endPos); - var rhsIsIdentifier = node.expression.kind === 67; - var counter = createTempVariable(268435456); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); - emitStart(node.expression); - write("var "); - emitNodeWithoutSourceMap(counter); - write(" = 0"); - emitEnd(node.expression); - if (!rhsIsIdentifier) { - write(", "); - emitStart(node.expression); - emitNodeWithoutSourceMap(rhsReference); - write(" = "); - emitNodeWithoutSourceMap(node.expression); - emitEnd(node.expression); - } - write("; "); - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write(" < "); - emitNodeWithCommentsAndWithoutSourcemap(rhsReference); - write(".length"); - emitEnd(node.initializer); - write("; "); - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write("++"); - emitEnd(node.initializer); - emitToken(18, node.expression.end); - write(" {"); - writeLine(); - increaseIndent(); - var rhsIterationValue = createElementAccessExpression(rhsReference, counter); - emitStart(node.initializer); - if (node.initializer.kind === 210) { - write("var "); - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length > 0) { - var declaration = variableDeclarationList.declarations[0]; - if (ts.isBindingPattern(declaration.name)) { - emitDestructuring(declaration, false, rhsIterationValue); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(declaration); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - emitNodeWithoutSourceMap(createTempVariable(0)); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - var assignmentExpression = createBinaryExpression(node.initializer, 55, rhsIterationValue, false); - if (node.initializer.kind === 162 || node.initializer.kind === 163) { - emitDestructuring(assignmentExpression, true, undefined); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); - } - } - emitEnd(node.initializer); - write(";"); - if (node.statement.kind === 190) { - emitLines(node.statement.statements); - } - else { - writeLine(); - emit(node.statement); - } - writeLine(); - decreaseIndent(); - write("}"); - } - function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 201 ? 68 : 73, node.pos); - emitOptional(" ", node.label); - write(";"); - } - function emitReturnStatement(node) { - emitToken(92, node.pos); - emitOptional(" ", node.expression); - write(";"); - } - function emitWithStatement(node) { - write("with ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitSwitchStatement(node) { - var endPos = emitToken(94, node.pos); - write(" "); - emitToken(17, endPos); - emit(node.expression); - endPos = emitToken(18, node.expression.end); - write(" "); - emitCaseBlock(node.caseBlock, endPos); - } - function emitCaseBlock(node, startPos) { - emitToken(15, startPos); - increaseIndent(); - emitLines(node.clauses); - decreaseIndent(); - writeLine(); - emitToken(16, node.clauses.end); - } - function nodeStartPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function nodeEndPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, node2.end); - } - function nodeEndIsOnSameLineAsNodeStart(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function emitCaseOrDefaultClause(node) { - if (node.kind === 239) { - write("case "); - emit(node.expression); - write(":"); - } - else { - write("default:"); - } - if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { - write(" "); - emit(node.statements[0]); - } - else { - increaseIndent(); - emitLines(node.statements); - decreaseIndent(); - } - } - function emitThrowStatement(node) { - write("throw "); - emit(node.expression); - write(";"); - } - function emitTryStatement(node) { - write("try "); - emit(node.tryBlock); - emit(node.catchClause); - if (node.finallyBlock) { - writeLine(); - write("finally "); - emit(node.finallyBlock); - } - } - function emitCatchClause(node) { - writeLine(); - var endPos = emitToken(70, node.pos); - write(" "); - emitToken(17, endPos); - emit(node.variableDeclaration); - emitToken(18, node.variableDeclaration ? node.variableDeclaration.end : endPos); - write(" "); - emitBlock(node.block); - } - function emitDebuggerStatement(node) { - emitToken(74, node.pos); - write(";"); - } - function emitLabelledStatement(node) { - emit(node.label); - write(": "); - emit(node.statement); - } - function getContainingModule(node) { - do { - node = node.parent; - } while (node && node.kind !== 216); - return node; - } - function emitContainingModuleName(node) { - var container = getContainingModule(node); - write(container ? getGeneratedNameForNode(container) : "exports"); - } - function emitModuleMemberName(node) { - emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 1) { - var container = getContainingModule(node); - if (container) { - write(getGeneratedNameForNode(container)); - write("."); - } - else if (languageVersion < 2 && compilerOptions.module !== 4) { - write("exports."); - } - } - emitNodeWithCommentsAndWithoutSourcemap(node.name); - emitEnd(node.name); - } - function createVoidZero() { - var zero = ts.createSynthesizedNode(8); - zero.text = "0"; - var result = ts.createSynthesizedNode(175); - result.expression = zero; - return result; - } - function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 246) { - ts.Debug.assert(!!(node.flags & 1024) || node.kind === 225); - if (compilerOptions.module === 1 || compilerOptions.module === 2 || compilerOptions.module === 3) { - if (!currentSourceFile.symbol.exports["___esModule"]) { - if (languageVersion === 1) { - write("Object.defineProperty(exports, \"__esModule\", { value: true });"); - writeLine(); - } - else if (languageVersion === 0) { - write("exports.__esModule = true;"); - writeLine(); - } - } - } - } - } - function emitExportMemberAssignment(node) { - if (node.flags & 1) { - writeLine(); - emitStart(node); - if (compilerOptions.module === 4 && node.parent === currentSourceFile) { - write(exportFunctionForFile + "(\""); - if (node.flags & 1024) { - write("default"); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(node.name); - } - write("\", "); - emitDeclarationName(node); - write(")"); - } - else { - if (node.flags & 1024) { - emitEs6ExportDefaultCompat(node); - if (languageVersion === 0) { - write("exports[\"default\"]"); - } - else { - write("exports.default"); - } - } - else { - emitModuleMemberName(node); - } - write(" = "); - emitDeclarationName(node); - } - emitEnd(node); - write(";"); - } - } - function emitExportMemberAssignments(name) { - if (compilerOptions.module === 4) { - return; - } - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { - var specifier = _b[_a]; - writeLine(); - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); - write(";"); - } - } - } - function emitExportSpecifierInSystemModule(specifier) { - ts.Debug.assert(compilerOptions.module === 4); - if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { - return; - } - writeLine(); - emitStart(specifier.name); - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - write("\", "); - emitExpressionIdentifier(specifier.propertyName || specifier.name); - write(")"); - emitEnd(specifier.name); - write(";"); - } - function emitDestructuring(root, isAssignmentExpressionStatement, value) { - var emitCount = 0; - var canDefineTempVariablesInPlace = false; - if (root.kind === 209) { - var isExported = ts.getCombinedNodeFlags(root) & 1; - var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); - canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; - } - else if (root.kind === 136) { - canDefineTempVariablesInPlace = true; - } - if (root.kind === 179) { - emitAssignmentExpression(root); - } - else { - ts.Debug.assert(!isAssignmentExpressionStatement); - emitBindingElement(root, value); - } - function emitAssignment(name, value) { - if (emitCount++) { - write(", "); - } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 || name.parent.kind === 161); - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(name); - write("\", "); - } - if (isVariableDeclarationOrBindingElement) { - emitModuleMemberName(name.parent); - } - else { - emit(name); - } - write(" = "); - emit(value); - if (exportChanged) { - write(")"); - } - } - function ensureIdentifier(expr, reuseIdentifierExpressions) { - if (expr.kind === 67 && reuseIdentifierExpressions) { - return expr; - } - var identifier = createTempVariable(0); - if (!canDefineTempVariablesInPlace) { - recordTempDeclaration(identifier); - } - emitAssignment(identifier, expr); - return identifier; - } - function createDefaultValueCheck(value, defaultValue) { - value = ensureIdentifier(value, true); - var equals = ts.createSynthesizedNode(179); - equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(32); - equals.right = createVoidZero(); - return createConditionalExpression(equals, defaultValue, value); - } - function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(180); - cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(52); - cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(53); - cond.whenFalse = whenFalse; - return cond; - } - function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(8); - node.text = "" + value; - return node; - } - function createPropertyAccessForDestructuringProperty(object, propName) { - var syntheticName = ts.createSynthesizedNode(propName.kind); - syntheticName.text = propName.text; - if (syntheticName.kind !== 67) { - return createElementAccessExpression(object, syntheticName); - } - return createPropertyAccessExpression(object, syntheticName); - } - function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(166); - var sliceIdentifier = ts.createSynthesizedNode(67); - sliceIdentifier.text = "slice"; - call.expression = createPropertyAccessExpression(value, sliceIdentifier); - call.arguments = ts.createSynthesizedNodeArray(); - call.arguments[0] = createNumericLiteral(sliceIndex); - return call; - } - function emitObjectLiteralAssignment(target, value) { - var properties = target.properties; - if (properties.length !== 1) { - value = ensureIdentifier(value, true); - } - for (var _a = 0; _a < properties.length; _a++) { - var p = properties[_a]; - if (p.kind === 243 || p.kind === 244) { - var propName = p.name; - emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); - } - } - } - function emitArrayLiteralAssignment(target, value) { - var elements = target.elements; - if (elements.length !== 1) { - value = ensureIdentifier(value, true); - } - for (var i = 0; i < elements.length; i++) { - var e = elements[i]; - if (e.kind !== 185) { - if (e.kind !== 183) { - emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === elements.length - 1) { - emitDestructuringAssignment(e.expression, createSliceCall(value, i)); - } - } - } - } - function emitDestructuringAssignment(target, value) { - if (target.kind === 179 && target.operatorToken.kind === 55) { - value = createDefaultValueCheck(value, target.right); - target = target.left; - } - if (target.kind === 163) { - emitObjectLiteralAssignment(target, value); - } - else if (target.kind === 162) { - emitArrayLiteralAssignment(target, value); - } - else { - emitAssignment(target, value); - } - } - function emitAssignmentExpression(root) { - var target = root.left; - var value = root.right; - if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { - emit(value); - } - else if (isAssignmentExpressionStatement) { - emitDestructuringAssignment(target, value); - } - else { - if (root.parent.kind !== 170) { - write("("); - } - value = ensureIdentifier(value, true); - emitDestructuringAssignment(target, value); - write(", "); - emit(value); - if (root.parent.kind !== 170) { - write(")"); - } - } - } - function emitBindingElement(target, value) { - if (target.initializer) { - value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; - } - else if (!value) { - value = createVoidZero(); - } - if (ts.isBindingPattern(target.name)) { - var pattern = target.name; - var elements = pattern.elements; - var numElements = elements.length; - if (numElements !== 1) { - value = ensureIdentifier(value, numElements !== 0); - } - for (var i = 0; i < numElements; i++) { - var element = elements[i]; - if (pattern.kind === 159) { - var propName = element.propertyName || element.name; - emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); - } - else if (element.kind !== 185) { - if (!element.dotDotDotToken) { - emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === numElements - 1) { - emitBindingElement(element, createSliceCall(value, i)); - } - } - } - } - else { - emitAssignment(target.name, value); - } - } - } - function emitVariableDeclaration(node) { - if (ts.isBindingPattern(node.name)) { - if (languageVersion < 2) { - emitDestructuring(node, false); - } - else { - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - else { - var initializer = node.initializer; - if (!initializer && languageVersion < 2) { - var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384) && - (getCombinedFlagsForIdentifier(node.name) & 16384); - if (isUninitializedLet && - node.parent.parent.kind !== 198 && - node.parent.parent.kind !== 199) { - initializer = createVoidZero(); - } - } - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(node.name); - write("\", "); - } - emitModuleMemberName(node); - emitOptional(" = ", initializer); - if (exportChanged) { - write(")"); - } - } - } - function emitExportVariableAssignments(node) { - if (node.kind === 185) { - return; - } - var name = node.name; - if (name.kind === 67) { - emitExportMemberAssignments(name); - } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, emitExportVariableAssignments); - } - } - function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 209 && node.parent.kind !== 161)) { - return 0; - } - return ts.getCombinedNodeFlags(node.parent); - } - function isES6ExportedDeclaration(node) { - return !!(node.flags & 1) && - languageVersion >= 2 && - node.parent.kind === 246; - } - function emitVariableStatement(node) { - var startIsEmitted = false; - if (node.flags & 1) { - if (isES6ExportedDeclaration(node)) { - write("export "); - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - } - else { - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - if (startIsEmitted) { - emitCommaList(node.declarationList.declarations); - write(";"); - } - else { - var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); - if (atLeastOneItem) { - write(";"); - } - } - if (languageVersion < 2 && node.parent === currentSourceFile) { - ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); - } - } - function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { - if (!(node.flags & 1)) { - return true; - } - if (isES6ExportedDeclaration(node)) { - return true; - } - for (var _a = 0, _b = node.declarationList.declarations; _a < _b.length; _a++) { - var declaration = _b[_a]; - if (declaration.initializer) { - return true; - } - } - return false; - } - function emitParameter(node) { - if (languageVersion < 2) { - if (ts.isBindingPattern(node.name)) { - var name_23 = createTempVariable(0); - if (!tempParameters) { - tempParameters = []; - } - tempParameters.push(name_23); - emit(name_23); - } - else { - emit(node.name); - } - } - else { - if (node.dotDotDotToken) { - write("..."); - } - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - function emitDefaultValueAssignments(node) { - if (languageVersion < 2) { - var tempIndex = 0; - ts.forEach(node.parameters, function (parameter) { - if (parameter.dotDotDotToken) { - return; - } - var paramName = parameter.name, initializer = parameter.initializer; - if (ts.isBindingPattern(paramName)) { - var hasBindingElements = paramName.elements.length > 0; - if (hasBindingElements || initializer) { - writeLine(); - write("var "); - if (hasBindingElements) { - emitDestructuring(parameter, false, tempParameters[tempIndex]); - } - else { - emit(tempParameters[tempIndex]); - write(" = "); - emit(initializer); - } - write(";"); - tempIndex++; - } - } - else if (initializer) { - writeLine(); - emitStart(parameter); - write("if ("); - emitNodeWithoutSourceMap(paramName); - write(" === void 0)"); - emitEnd(parameter); - write(" { "); - emitStart(parameter); - emitNodeWithCommentsAndWithoutSourcemap(paramName); - write(" = "); - emitNodeWithCommentsAndWithoutSourcemap(initializer); - emitEnd(parameter); - write("; }"); - } - }); - } - } - function emitRestParameter(node) { - if (languageVersion < 2 && ts.hasRestParameter(node)) { - var restIndex = node.parameters.length - 1; - var restParam = node.parameters[restIndex]; - if (ts.isBindingPattern(restParam.name)) { - return; - } - var tempName = createTempVariable(268435456).text; - writeLine(); - emitLeadingComments(restParam); - emitStart(restParam); - write("var "); - emitNodeWithCommentsAndWithoutSourcemap(restParam.name); - write(" = [];"); - emitEnd(restParam); - emitTrailingComments(restParam); - writeLine(); - write("for ("); - emitStart(restParam); - write("var " + tempName + " = " + restIndex + ";"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + " < arguments.length;"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + "++"); - emitEnd(restParam); - write(") {"); - increaseIndent(); - writeLine(); - emitStart(restParam); - emitNodeWithCommentsAndWithoutSourcemap(restParam.name); - write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); - emitEnd(restParam); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitAccessor(node) { - write(node.kind === 143 ? "get " : "set "); - emit(node.name); - emitSignatureAndBody(node); - } - function shouldEmitAsArrowFunction(node) { - return node.kind === 172 && languageVersion >= 2; - } - function emitDeclarationName(node) { - if (node.name) { - emitNodeWithCommentsAndWithoutSourcemap(node.name); - } - else { - write(getGeneratedNameForNode(node)); - } - } - function shouldEmitFunctionName(node) { - if (node.kind === 171) { - return !!node.name; - } - if (node.kind === 211) { - return !!node.name || languageVersion < 2; - } - } - function emitFunctionDeclaration(node) { - if (ts.nodeIsMissing(node.body)) { - return emitCommentsOnNotEmittedNode(node); - } - if (node.kind !== 141 && node.kind !== 140 && - node.parent && node.parent.kind !== 243 && - node.parent.kind !== 166) { - emitLeadingComments(node); - } - emitStart(node); - if (!shouldEmitAsArrowFunction(node)) { - if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 1024) { - write("default "); - } - } - write("function"); - if (languageVersion >= 2 && node.asteriskToken) { - write("*"); - } - write(" "); - } - if (shouldEmitFunctionName(node)) { - emitDeclarationName(node); - } - emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 211 && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - emitEnd(node); - if (node.kind !== 141 && node.kind !== 140) { - emitTrailingComments(node); - } - } - function emitCaptureThisForNodeIfNecessary(node) { - if (resolver.getNodeCheckFlags(node) & 4) { - writeLine(); - emitStart(node); - write("var _this = this;"); - emitEnd(node); - } - } - function emitSignatureParameters(node) { - increaseIndent(); - write("("); - if (node) { - var parameters = node.parameters; - var omitCount = languageVersion < 2 && ts.hasRestParameter(node) ? 1 : 0; - emitList(parameters, 0, parameters.length - omitCount, false, false); - } - write(")"); - decreaseIndent(); - } - function emitSignatureParametersForArrow(node) { - if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { - emit(node.parameters[0]); - return; - } - emitSignatureParameters(node); - } - function emitAsyncFunctionBodyForES6(node) { - var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 172; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; - var args; - if (!isArrowFunction) { - write(" {"); - increaseIndent(); - writeLine(); - write("return"); - } - write(" __awaiter(this"); - if (hasLexicalArguments) { - write(", arguments"); - } - else { - write(", void 0"); - } - if (promiseConstructor) { - write(", "); - emitNodeWithoutSourceMap(promiseConstructor); - } - else { - write(", Promise"); - } - if (hasLexicalArguments) { - write(", function* (_arguments)"); - } - else { - write(", function* ()"); - } - emitFunctionBody(node); - write(")"); - if (!isArrowFunction) { - write(";"); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitFunctionBody(node) { - if (!node.body) { - write(" { }"); - } - else { - if (node.body.kind === 190) { - emitBlockFunctionBody(node, node.body); - } - else { - emitExpressionFunctionBody(node, node.body); - } - } - } - function emitSignatureAndBody(node) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - if (shouldEmitAsArrowFunction(node)) { - emitSignatureParametersForArrow(node); - write(" =>"); - } - else { - emitSignatureParameters(node); - } - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync && languageVersion === 2) { - emitAsyncFunctionBodyForES6(node); - } - else { - emitFunctionBody(node); - } - if (!isES6ExportedDeclaration(node)) { - emitExportMemberAssignment(node); - } - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - function emitFunctionBodyPreamble(node) { - emitCaptureThisForNodeIfNecessary(node); - emitDefaultValueAssignments(node); - emitRestParameter(node); - } - function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2 || node.flags & 512) { - emitDownLevelExpressionFunctionBody(node, body); - return; - } - write(" "); - var current = body; - while (current.kind === 169) { - current = current.expression; - } - emitParenthesizedIf(body, current.kind === 163); - } - function emitDownLevelExpressionFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - increaseIndent(); - var outPos = writer.getTextPos(); - emitDetachedComments(node.body); - emitFunctionBodyPreamble(node); - var preambleEmitted = writer.getTextPos() !== outPos; - decreaseIndent(); - if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { - write(" "); - emitStart(body); - write("return "); - emit(body); - emitEnd(body); - write(";"); - emitTempDeclarations(false); - write(" "); - } - else { - increaseIndent(); - writeLine(); - emitLeadingComments(node.body); - write("return "); - emit(body); - write(";"); - emitTrailingComments(node.body); - emitTempDeclarations(true); - decreaseIndent(); - writeLine(); - } - emitStart(node.body); - write("}"); - emitEnd(node.body); - scopeEmitEnd(); - } - function emitBlockFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - var initialTextPos = writer.getTextPos(); - increaseIndent(); - emitDetachedComments(body.statements); - var startIndex = emitDirectivePrologues(body.statements, true); - emitFunctionBodyPreamble(node); - decreaseIndent(); - var preambleEmitted = writer.getTextPos() !== initialTextPos; - if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { - for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { - var statement = _b[_a]; - write(" "); - emit(statement); - } - emitTempDeclarations(false); - write(" "); - emitLeadingCommentsOfPosition(body.statements.end); - } - else { - increaseIndent(); - emitLinesStartingAt(body.statements, startIndex); - emitTempDeclarations(true); - writeLine(); - emitLeadingCommentsOfPosition(body.statements.end); - decreaseIndent(); - } - emitToken(16, body.statements.end); - scopeEmitEnd(); - } - function findInitialSuperCall(ctor) { - if (ctor.body) { - var statement = ctor.body.statements[0]; - if (statement && statement.kind === 193) { - var expr = statement.expression; - if (expr && expr.kind === 166) { - var func = expr.expression; - if (func && func.kind === 93) { - return statement; - } - } - } - } - } - function emitParameterPropertyAssignments(node) { - ts.forEach(node.parameters, function (param) { - if (param.flags & 112) { - writeLine(); - emitStart(param); - emitStart(param.name); - write("this."); - emitNodeWithoutSourceMap(param.name); - emitEnd(param.name); - write(" = "); - emit(param.name); - write(";"); - emitEnd(param); - } - }); - } - function emitMemberAccessForPropertyName(memberName) { - if (memberName.kind === 9 || memberName.kind === 8) { - write("["); - emitNodeWithCommentsAndWithoutSourcemap(memberName); - write("]"); - } - else if (memberName.kind === 134) { - emitComputedPropertyName(memberName); - } - else { - write("."); - emitNodeWithCommentsAndWithoutSourcemap(memberName); - } - } - function getInitializedProperties(node, isStatic) { - var properties = []; - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if (member.kind === 139 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { - properties.push(member); - } - } - return properties; - } - function emitPropertyDeclarations(node, properties) { - for (var _a = 0; _a < properties.length; _a++) { - var property = properties[_a]; - emitPropertyDeclaration(node, property); - } - } - function emitPropertyDeclaration(node, property, receiver, isExpression) { - writeLine(); - emitLeadingComments(property); - emitStart(property); - emitStart(property.name); - if (receiver) { - emit(receiver); - } - else { - if (property.flags & 128) { - emitDeclarationName(node); - } - else { - write("this"); - } - } - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - emit(property.initializer); - if (!isExpression) { - write(";"); - } - emitEnd(property); - emitTrailingComments(property); - } - function emitMemberFunctionsForES5AndLower(node) { - ts.forEach(node.members, function (member) { - if (member.kind === 189) { - writeLine(); - write(";"); - } - else if (member.kind === 141 || node.kind === 140) { - if (!member.body) { - return emitCommentsOnNotEmittedNode(member); - } - writeLine(); - emitLeadingComments(member); - emitStart(member); - emitStart(member.name); - emitClassMemberPrefix(node, member); - emitMemberAccessForPropertyName(member.name); - emitEnd(member.name); - write(" = "); - emitFunctionDeclaration(member); - emitEnd(member); - write(";"); - emitTrailingComments(member); - } - else if (member.kind === 143 || member.kind === 144) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member === accessors.firstAccessor) { - writeLine(); - emitStart(member); - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("});"); - emitEnd(member); - } - } - }); - } - function emitMemberFunctionsForES6AndHigher(node) { - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if ((member.kind === 141 || node.kind === 140) && !member.body) { - emitCommentsOnNotEmittedNode(member); - } - else if (member.kind === 141 || - member.kind === 143 || - member.kind === 144) { - writeLine(); - emitLeadingComments(member); - emitStart(member); - if (member.flags & 128) { - write("static "); - } - if (member.kind === 143) { - write("get "); - } - else if (member.kind === 144) { - write("set "); - } - if (member.asteriskToken) { - write("*"); - } - emit(member.name); - emitSignatureAndBody(member); - emitEnd(member); - emitTrailingComments(member); - } - else if (member.kind === 189) { - writeLine(); - write(";"); - } - } - } - function emitConstructor(node, baseTypeElement) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - emitConstructorWorker(node, baseTypeElement); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - function emitConstructorWorker(node, baseTypeElement) { - var hasInstancePropertyWithInitializer = false; - ts.forEach(node.members, function (member) { - if (member.kind === 142 && !member.body) { - emitCommentsOnNotEmittedNode(member); - } - if (member.kind === 139 && 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 (baseTypeElement) { - write("(...args)"); - } - else { - write("()"); - } - } - } - var startIndex = 0; - write(" {"); - scopeEmitStart(node, "constructor"); - increaseIndent(); - if (ctor) { - startIndex = emitDirectivePrologues(ctor.body.statements, true); - emitDetachedComments(ctor.body.statements); - } - emitCaptureThisForNodeIfNecessary(node); - var superCall; - if (ctor) { - emitDefaultValueAssignments(ctor); - emitRestParameter(ctor); - if (baseTypeElement) { - superCall = findInitialSuperCall(ctor); - if (superCall) { - writeLine(); - emit(superCall); - } - } - emitParameterPropertyAssignments(ctor); - } - else { - if (baseTypeElement) { - writeLine(); - emitStart(baseTypeElement); - if (languageVersion < 2) { - write("_super.apply(this, arguments);"); - } - else { - write("super(...args);"); - } - emitEnd(baseTypeElement); - } - } - emitPropertyDeclarations(node, getInitializedProperties(node, false)); - if (ctor) { - var statements = ctor.body.statements; - if (superCall) { - statements = statements.slice(1); - } - emitLinesStartingAt(statements, startIndex); - } - emitTempDeclarations(true); - writeLine(); - if (ctor) { - emitLeadingCommentsOfPosition(ctor.body.statements.end); - } - decreaseIndent(); - emitToken(16, ctor ? ctor.body.statements.end : node.members.end); - scopeEmitEnd(); - emitEnd(ctor || node); - if (ctor) { - emitTrailingComments(ctor); - } - } - function emitClassExpression(node) { - return emitClassLikeDeclaration(node); - } - function emitClassDeclaration(node) { - return emitClassLikeDeclaration(node); - } - function emitClassLikeDeclaration(node) { - if (languageVersion < 2) { - emitClassLikeDeclarationBelowES6(node); - } - else { - emitClassLikeDeclarationForES6AndHigher(node); - } - } - function emitClassLikeDeclarationForES6AndHigher(node) { - var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 212) { - if (thisNodeIsDecorated) { - if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { - write("export "); - } - write("let "); - emitDeclarationName(node); - write(" = "); - } - else if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 1024) { - write("default "); - } - } - } - var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184; - var tempVariable; - if (isClassExpressionWithStaticProperties) { - tempVariable = createAndRecordTempVariable(0); - write("("); - increaseIndent(); - emit(tempVariable); - write(" = "); - } - write("class"); - if ((node.name || !(node.flags & 1024)) && !thisNodeIsDecorated) { - write(" "); - emitDeclarationName(node); - } - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - write(" extends "); - emit(baseTypeNode.expression); - } - write(" {"); - increaseIndent(); - scopeEmitStart(node); - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES6AndHigher(node); - decreaseIndent(); - writeLine(); - emitToken(16, node.members.end); - scopeEmitEnd(); - if (thisNodeIsDecorated) { - write(";"); - } - if (isClassExpressionWithStaticProperties) { - for (var _a = 0; _a < staticProperties.length; _a++) { - var property = staticProperties[_a]; - write(","); - writeLine(); - emitPropertyDeclaration(node, property, tempVariable, true); - } - write(","); - writeLine(); - emit(tempVariable); - decreaseIndent(); - write(")"); - } - else { - writeLine(); - emitPropertyDeclarations(node, staticProperties); - 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 & 1024) && thisNodeIsDecorated) { - writeLine(); - write("export default "); - emitDeclarationName(node); - write(";"); - } - } - function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 212) { - if (!shouldHoistDeclarationInSystemJsModule(node)) { - write("var "); - } - emitDeclarationName(node); - write(" = "); - } - write("(function ("); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - 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) { - writeLine(); - emitStart(baseTypeNode); - write("__extends("); - emitDeclarationName(node); - write(", _super);"); - emitEnd(baseTypeNode); - } - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES5AndLower(node); - emitPropertyDeclarations(node, getInitializedProperties(node, true)); - writeLine(); - emitDecoratorsOfClass(node); - writeLine(); - emitToken(16, node.members.end, function () { - write("return "); - emitDeclarationName(node); - }); - write(";"); - emitTempDeclarations(true); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; - decreaseIndent(); - writeLine(); - emitToken(16, node.members.end); - scopeEmitEnd(); - emitStart(node); - write(")("); - if (baseTypeNode) { - emit(baseTypeNode.expression); - } - write(")"); - if (node.kind === 212) { - write(";"); - } - emitEnd(node); - if (node.kind === 212) { - emitExportMemberAssignment(node); - } - if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - } - 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 decorators = node.decorators; - var constructor = ts.getFirstConstructorWithBody(node); - var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); - if (!decorators && !hasDecoratedParameters) { - return; - } - writeLine(); - emitStart(node); - emitDeclarationName(node); - write(" = __decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(constructor, argumentsWritten > 0); - emitSerializedTypeMetadata(node, argumentsWritten >= 0); - decreaseIndent(); - writeLine(); - write("], "); - emitDeclarationName(node); - write(");"); - emitEnd(node); - writeLine(); - } - function emitDecoratorsOfMembers(node, staticFlag) { - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if ((member.flags & 128) !== staticFlag) { - continue; - } - if (!ts.nodeCanBeDecorated(member)) { - continue; - } - if (!ts.nodeOrChildIsDecorated(member)) { - continue; - } - var decorators = void 0; - var functionLikeMember = void 0; - if (ts.isAccessor(member)) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member !== accessors.firstAccessor) { - continue; - } - decorators = accessors.firstAccessor.decorators; - if (!decorators && accessors.secondAccessor) { - decorators = accessors.secondAccessor.decorators; - } - functionLikeMember = accessors.setAccessor; - } - else { - decorators = member.decorators; - if (member.kind === 141) { - functionLikeMember = member; - } - } - writeLine(); - emitStart(member); - if (member.kind !== 139) { - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(","); - increaseIndent(); - writeLine(); - } - write("__decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); - emitSerializedTypeMetadata(member, argumentsWritten > 0); - decreaseIndent(); - writeLine(); - write("], "); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - if (member.kind !== 139) { - write(", Object.getOwnPropertyDescriptor("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write("))"); - decreaseIndent(); - } - write(");"); - emitEnd(member); - writeLine(); - } - } - function emitDecoratorsOfParameters(node, leadingComma) { - var argumentsWritten = 0; - if (node) { - var parameterIndex = 0; - for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { - var parameter = _b[_a]; - if (ts.nodeIsDecorated(parameter)) { - var decorators = parameter.decorators; - argumentsWritten += emitList(decorators, 0, decorators.length, true, false, leadingComma, true, function (decorator) { - emitStart(decorator); - write("__param(" + parameterIndex + ", "); - emit(decorator.expression); - write(")"); - emitEnd(decorator); - }); - leadingComma = true; - } - ++parameterIndex; - } - } - return argumentsWritten; - } - function shouldEmitTypeMetadata(node) { - switch (node.kind) { - case 141: - case 143: - case 144: - case 139: - return true; - } - return false; - } - function shouldEmitReturnTypeMetadata(node) { - switch (node.kind) { - case 141: - return true; - } - return false; - } - function shouldEmitParamTypesMetadata(node) { - switch (node.kind) { - case 212: - case 141: - case 144: - return true; - } - return false; - } - function emitSerializedTypeOfNode(node) { - switch (node.kind) { - case 212: - write("Function"); - return; - case 139: - emitSerializedTypeNode(node.type); - return; - case 136: - emitSerializedTypeNode(node.type); - return; - case 143: - emitSerializedTypeNode(node.type); - return; - case 144: - emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - return; - } - if (ts.isFunctionLike(node)) { - write("Function"); - return; - } - write("void 0"); - } - function emitSerializedTypeNode(node) { - if (node) { - switch (node.kind) { - case 101: - write("void 0"); - return; - case 158: - emitSerializedTypeNode(node.type); - return; - case 150: - case 151: - write("Function"); - return; - case 154: - case 155: - write("Array"); - return; - case 148: - case 118: - write("Boolean"); - return; - case 128: - case 9: - write("String"); - return; - case 126: - write("Number"); - return; - case 129: - write("Symbol"); - return; - case 149: - emitSerializedTypeReferenceNode(node); - return; - case 152: - case 153: - case 156: - case 157: - case 115: - break; - default: - ts.Debug.fail("Cannot serialize unexpected type node."); - break; - } - } - write("Object"); - } - function emitSerializedTypeReferenceNode(node) { - var location = node.parent; - while (ts.isDeclaration(location) || ts.isTypeNode(location)) { - location = location.parent; - } - var typeName = ts.cloneEntityName(node.typeName); - typeName.parent = location; - var result = resolver.getTypeReferenceSerializationKind(typeName); - switch (result) { - case ts.TypeReferenceSerializationKind.Unknown: - var temp = createAndRecordTempVariable(0); - write("(typeof ("); - emitNodeWithoutSourceMap(temp); - write(" = "); - emitEntityNameAsExpression(typeName, true); - write(") === 'function' && "); - emitNodeWithoutSourceMap(temp); - write(") || Object"); - break; - case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: - emitEntityNameAsExpression(typeName, false); - break; - case ts.TypeReferenceSerializationKind.VoidType: - write("void 0"); - break; - case ts.TypeReferenceSerializationKind.BooleanType: - write("Boolean"); - break; - case ts.TypeReferenceSerializationKind.NumberLikeType: - write("Number"); - break; - case ts.TypeReferenceSerializationKind.StringLikeType: - write("String"); - break; - case ts.TypeReferenceSerializationKind.ArrayLikeType: - write("Array"); - break; - case ts.TypeReferenceSerializationKind.ESSymbolType: - if (languageVersion < 2) { - write("typeof Symbol === 'function' ? Symbol : Object"); - } - else { - write("Symbol"); - } - break; - case ts.TypeReferenceSerializationKind.TypeWithCallSignature: - write("Function"); - break; - case ts.TypeReferenceSerializationKind.ObjectType: - write("Object"); - break; - } - } - function emitSerializedParameterTypesOfNode(node) { - if (node) { - var valueDeclaration; - if (node.kind === 212) { - valueDeclaration = ts.getFirstConstructorWithBody(node); - } - else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { - valueDeclaration = node; - } - if (valueDeclaration) { - var parameters = valueDeclaration.parameters; - var parameterCount = parameters.length; - if (parameterCount > 0) { - for (var i = 0; i < parameterCount; i++) { - if (i > 0) { - write(", "); - } - if (parameters[i].dotDotDotToken) { - var parameterType = parameters[i].type; - if (parameterType.kind === 154) { - parameterType = parameterType.elementType; - } - else if (parameterType.kind === 149 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { - parameterType = parameterType.typeArguments[0]; - } - else { - parameterType = undefined; - } - emitSerializedTypeNode(parameterType); - } - else { - emitSerializedTypeOfNode(parameters[i]); - } - } - } - } - } - } - function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node) && node.type) { - emitSerializedTypeNode(node.type); - return; - } - write("void 0"); - } - function emitSerializedTypeMetadata(node, writeComma) { - var argumentsWritten = 0; - if (compilerOptions.emitDecoratorMetadata) { - if (shouldEmitTypeMetadata(node)) { - if (writeComma) { - write(", "); - } - writeLine(); - write("__metadata('design:type', "); - emitSerializedTypeOfNode(node); - write(")"); - argumentsWritten++; - } - if (shouldEmitParamTypesMetadata(node)) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:paramtypes', ["); - emitSerializedParameterTypesOfNode(node); - write("])"); - argumentsWritten++; - } - if (shouldEmitReturnTypeMetadata(node)) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:returntype', "); - emitSerializedReturnTypeOfNode(node); - write(")"); - argumentsWritten++; - } - } - return argumentsWritten; - } - function emitInterfaceDeclaration(node) { - emitCommentsOnNotEmittedNode(node); - } - function shouldEmitEnumDeclaration(node) { - var isConstEnum = ts.isConst(node); - return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; - } - function emitEnumDeclaration(node) { - if (!shouldEmitEnumDeclaration(node)) { - return; - } - if (!shouldHoistDeclarationInSystemJsModule(node)) { - if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - emitEnd(node); - write(";"); - } - } - writeLine(); - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") {"); - increaseIndent(); - scopeEmitStart(node); - emitLines(node.members); - decreaseIndent(); - writeLine(); - emitToken(16, node.members.end); - scopeEmitEnd(); - write(")("); - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1 && !shouldHoistDeclarationInSystemJsModule(node)) { - writeLine(); - emitStart(node); - write("var "); - emit(node.name); - write(" = "); - emitModuleMemberName(node); - emitEnd(node); - write(";"); - } - if (languageVersion < 2 && node.parent === currentSourceFile) { - if (compilerOptions.module === 4 && (node.flags & 1)) { - writeLine(); - write(exportFunctionForFile + "(\""); - emitDeclarationName(node); - write("\", "); - emitDeclarationName(node); - write(");"); - } - emitExportMemberAssignments(node.name); - } - } - function emitEnumMember(node) { - var enumParent = node.parent; - emitStart(node); - write(getGeneratedNameForNode(enumParent)); - write("["); - write(getGeneratedNameForNode(enumParent)); - write("["); - emitExpressionForPropertyName(node.name); - write("] = "); - writeEnumMemberDeclarationValue(node); - write("] = "); - emitExpressionForPropertyName(node.name); - emitEnd(node); - write(";"); - } - function writeEnumMemberDeclarationValue(member) { - var value = resolver.getConstantValue(member); - if (value !== undefined) { - write(value.toString()); - return; - } - else if (member.initializer) { - emit(member.initializer); - } - else { - write("undefined"); - } - } - function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 216) { - var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); - return recursiveInnerModule || moduleDeclaration.body; - } - } - function shouldEmitModuleDeclaration(node) { - return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); - } - function isModuleMergedWithES6Class(node) { - return languageVersion === 2 && !!(resolver.getNodeCheckFlags(node) & 32768); - } - function emitModuleDeclaration(node) { - var shouldEmit = shouldEmitModuleDeclaration(node); - if (!shouldEmit) { - return emitCommentsOnNotEmittedNode(node); - } - var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); - var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); - if (emitVarForModule) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - write(";"); - emitEnd(node); - writeLine(); - } - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") "); - if (node.body.kind === 217) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - tempFlags = 0; - tempVariables = undefined; - emit(node.body); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - } - else { - write("{"); - increaseIndent(); - scopeEmitStart(node); - emitCaptureThisForNodeIfNecessary(node); - writeLine(); - emit(node.body); - decreaseIndent(); - writeLine(); - var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(16, moduleBlock.statements.end); - scopeEmitEnd(); - } - write(")("); - if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { - emit(node.name); - write(" = "); - } - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 67 && node.parent === currentSourceFile) { - if (compilerOptions.module === 4 && (node.flags & 1)) { - writeLine(); - write(exportFunctionForFile + "(\""); - emitDeclarationName(node); - write("\", "); - emitDeclarationName(node); - write(");"); - } - emitExportMemberAssignments(node.name); - } - } - function tryRenameExternalModule(moduleName) { - if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { - return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; - } - return undefined; - } - function emitRequire(moduleName) { - if (moduleName.kind === 9) { - write("require("); - var text = tryRenameExternalModule(moduleName); - if (text) { - write(text); - } - else { - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - } - emitToken(18, moduleName.end); - } - else { - write("require()"); - } - } - function getNamespaceDeclarationNode(node) { - if (node.kind === 219) { - return node; - } - var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222) { - return importClause.namedBindings; - } - } - function isDefaultImport(node) { - return node.kind === 220 && 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) { - 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 === 222) { - 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 === 219 && (node.flags & 1) !== 0; - var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (compilerOptions.module !== 2) { - emitLeadingComments(node); - emitStart(node); - if (namespaceDeclaration && !isDefaultImport(node)) { - if (!isExportedImport) - write("var "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - } - else { - var isNakedImport = 220 && !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 (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)) { - emitExternalImportDeclaration(node); - return; - } - if (resolver.isReferencedAliasDeclaration(node) || - (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { - emitLeadingComments(node); - emitStart(node); - var variableDeclarationIsHoisted = shouldHoistVariable(node, true); - var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, true); - if (!variableDeclarationIsHoisted) { - ts.Debug.assert(!isExported); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); - } - else if (!(node.flags & 1)) { - write("var "); - } - } - if (isExported) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); - write("\", "); - } - emitModuleMemberName(node); - write(" = "); - emit(node.moduleReference); - if (isExported) { - write(")"); - } - write(";"); - emitEnd(node); - emitExportImportAssignments(node); - emitTrailingComments(node); - } - } - function emitExportDeclaration(node) { - ts.Debug.assert(compilerOptions.module !== 4); - 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; _a < _b.length; _a++) { - var specifier = _b[_a]; - if (resolver.isValueAliasDeclaration(specifier)) { - writeLine(); - emitStart(specifier); - emitContainingModuleName(specifier); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - write(" = "); - write(generatedName); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); - write(";"); - emitEnd(specifier); - } - } - } - else { - writeLine(); - write("__export("); - if (compilerOptions.module !== 2) { - emitRequire(ts.getExternalModuleName(node)); - } - else { - write(generatedName); - } - write(");"); - } - emitEnd(node); - } - } - else { - if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - write("export "); - if (node.exportClause) { - write("{ "); - emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); - write(" }"); - } - else { - write("*"); - } - if (node.moduleSpecifier) { - write(" from "); - emit(node.moduleSpecifier); - } - write(";"); - } - } - } - function emitExportOrImportSpecifierList(specifiers, shouldEmit) { - ts.Debug.assert(languageVersion >= 2); - var needsComma = false; - for (var _a = 0; _a < specifiers.length; _a++) { - var specifier = specifiers[_a]; - if (shouldEmit(specifier)) { - if (needsComma) { - write(", "); - } - if (specifier.propertyName) { - emit(specifier.propertyName); - write(" as "); - } - emit(specifier.name); - 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 !== 211 && - expression.kind !== 212) { - write(";"); - } - emitEnd(node); - } - else { - writeLine(); - emitStart(node); - if (compilerOptions.module === 4) { - write(exportFunctionForFile + "(\"default\","); - emit(node.expression); - write(")"); - } - else { - emitEs6ExportDefaultCompat(node); - emitContainingModuleName(node); - if (languageVersion === 0) { - write("[\"default\"] = "); - } - else { - write(".default = "); - } - emit(node.expression); - } - write(";"); - emitEnd(node); - } - } - } - function collectExternalModuleInfo(sourceFile) { - externalImports = []; - exportSpecifiers = {}; - exportEquals = undefined; - hasExportStars = false; - for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { - var node = _b[_a]; - switch (node.kind) { - case 220: - if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, true)) { - externalImports.push(node); - } - break; - case 219: - if (node.moduleReference.kind === 230 && resolver.isReferencedAliasDeclaration(node)) { - externalImports.push(node); - } - break; - case 226: - if (node.moduleSpecifier) { - if (!node.exportClause) { - externalImports.push(node); - hasExportStars = true; - } - else if (resolver.isValueAliasDeclaration(node)) { - externalImports.push(node); - } - } - else { - for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { - var specifier = _d[_c]; - var name_24 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier); - } - } - break; - case 225: - if (node.isExportEquals && !exportEquals) { - exportEquals = node; - } - break; - } - } - } - 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 getLocalNameForExternalImport(node) { - var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (namespaceDeclaration && !isDefaultImport(node)) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); - } - if (node.kind === 220 && node.importClause) { - return getGeneratedNameForNode(node); - } - if (node.kind === 226 && node.moduleSpecifier) { - return getGeneratedNameForNode(node); - } - } - function getExternalModuleNameText(importNode) { - var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 9) { - return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); - } - return undefined; - } - function emitVariableDeclarationsForImports() { - if (externalImports.length === 0) { - return; - } - writeLine(); - var started = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var importNode = externalImports[_a]; - var skipNode = importNode.kind === 226 || - (importNode.kind === 220 && !importNode.importClause); - if (skipNode) { - continue; - } - if (!started) { - write("var "); - started = true; - } - else { - write(", "); - } - write(getLocalNameForExternalImport(importNode)); - } - if (started) { - write(";"); - } - } - function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { - if (!hasExportStars) { - return undefined; - } - if (!exportedDeclarations && ts.isEmpty(exportSpecifiers)) { - var hasExportDeclarationWithExportClause = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var externalImport = externalImports[_a]; - if (externalImport.kind === 226 && externalImport.exportClause) { - hasExportDeclarationWithExportClause = true; - break; - } - } - if (!hasExportDeclarationWithExportClause) { - return emitExportStarFunction(undefined); - } - } - var exportedNamesStorageRef = makeUniqueName("exportedNames"); - writeLine(); - write("var " + exportedNamesStorageRef + " = {"); - increaseIndent(); - var started = false; - if (exportedDeclarations) { - for (var i = 0; i < exportedDeclarations.length; ++i) { - writeExportedName(exportedDeclarations[i]); - } - } - if (exportSpecifiers) { - for (var n in exportSpecifiers) { - for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { - var specifier = _c[_b]; - writeExportedName(specifier.name); - } - } - } - for (var _d = 0; _d < externalImports.length; _d++) { - var externalImport = externalImports[_d]; - if (externalImport.kind !== 226) { - continue; - } - var exportDecl = externalImport; - if (!exportDecl.exportClause) { - continue; - } - for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { - var element = _f[_e]; - writeExportedName(element.name || element.propertyName); - } - } - decreaseIndent(); - writeLine(); - write("};"); - return emitExportStarFunction(exportedNamesStorageRef); - function emitExportStarFunction(localNames) { - var exportStarFunction = makeUniqueName("exportStar"); - writeLine(); - write("function " + exportStarFunction + "(m) {"); - increaseIndent(); - writeLine(); - write("var exports = {};"); - writeLine(); - write("for(var n in m) {"); - increaseIndent(); - writeLine(); - write("if (n !== \"default\""); - if (localNames) { - write("&& !" + localNames + ".hasOwnProperty(n)"); - } - write(") exports[n] = m[n];"); - decreaseIndent(); - writeLine(); - write("}"); - writeLine(); - write(exportFunctionForFile + "(exports);"); - decreaseIndent(); - writeLine(); - write("}"); - return exportStarFunction; - } - function writeExportedName(node) { - if (node.kind !== 67 && node.flags & 1024) { - return; - } - if (started) { - write(","); - } - else { - started = true; - } - writeLine(); - write("'"); - if (node.kind === 67) { - emitNodeWithCommentsAndWithoutSourcemap(node); - } - else { - emitDeclarationName(node); - } - write("': true"); - } - } - function processTopLevelVariableAndFunctionDeclarations(node) { - var hoistedVars; - var hoistedFunctionDeclarations; - var exportedDeclarations; - visit(node); - if (hoistedVars) { - writeLine(); - write("var "); - var seen = {}; - for (var i = 0; i < hoistedVars.length; ++i) { - var local = hoistedVars[i]; - var name_25 = local.kind === 67 - ? local - : local.name; - if (name_25) { - var text = ts.unescapeIdentifier(name_25.text); - if (ts.hasProperty(seen, text)) { - continue; - } - else { - seen[text] = text; - } - } - if (i !== 0) { - write(", "); - } - if (local.kind === 212 || local.kind === 216 || local.kind === 215) { - emitDeclarationName(local); - } - else { - emit(local); - } - var flags = ts.getCombinedNodeFlags(local.kind === 67 ? local.parent : local); - if (flags & 1) { - if (!exportedDeclarations) { - exportedDeclarations = []; - } - exportedDeclarations.push(local); - } - } - write(";"); - } - if (hoistedFunctionDeclarations) { - for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { - var f = hoistedFunctionDeclarations[_a]; - writeLine(); - emit(f); - if (f.flags & 1) { - if (!exportedDeclarations) { - exportedDeclarations = []; - } - exportedDeclarations.push(f); - } - } - } - return exportedDeclarations; - function visit(node) { - if (node.flags & 2) { - return; - } - if (node.kind === 211) { - if (!hoistedFunctionDeclarations) { - hoistedFunctionDeclarations = []; - } - hoistedFunctionDeclarations.push(node); - return; - } - if (node.kind === 212) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - return; - } - if (node.kind === 215) { - if (shouldEmitEnumDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - } - return; - } - if (node.kind === 216) { - if (shouldEmitModuleDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - } - return; - } - if (node.kind === 209 || node.kind === 161) { - if (shouldHoistVariable(node, false)) { - var name_26 = node.name; - if (name_26.kind === 67) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(name_26); - } - else { - ts.forEachChild(name_26, visit); - } - } - return; - } - if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node.name); - return; - } - if (ts.isBindingPattern(node)) { - ts.forEach(node.elements, visit); - return; - } - if (!ts.isDeclaration(node)) { - ts.forEachChild(node, visit); - } - } - } - function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { - if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { - return false; - } - return (ts.getCombinedNodeFlags(node) & 49152) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 246; - } - function isCurrentFileSystemExternalModule() { - return compilerOptions.module === 4 && ts.isExternalModule(currentSourceFile); - } - function emitSystemModuleBody(node, dependencyGroups, startIndex) { - emitVariableDeclarationsForImports(); - writeLine(); - var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); - var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); - writeLine(); - write("return {"); - increaseIndent(); - writeLine(); - emitSetters(exportStarFunction, dependencyGroups); - writeLine(); - emitExecute(node, startIndex); - decreaseIndent(); - writeLine(); - write("}"); - emitTempDeclarations(true); - } - function emitSetters(exportStarFunction, dependencyGroups) { - write("setters:["); - for (var i = 0; i < dependencyGroups.length; ++i) { - if (i !== 0) { - write(","); - } - writeLine(); - increaseIndent(); - var group = dependencyGroups[i]; - var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); - write("function (" + parameterName + ") {"); - increaseIndent(); - for (var _a = 0; _a < group.length; _a++) { - var entry = group[_a]; - var importVariableName = getLocalNameForExternalImport(entry) || ""; - switch (entry.kind) { - case 220: - if (!entry.importClause) { - break; - } - case 219: - ts.Debug.assert(importVariableName !== ""); - writeLine(); - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - break; - case 226: - ts.Debug.assert(importVariableName !== ""); - if (entry.exportClause) { - writeLine(); - write(exportFunctionForFile + "({"); - writeLine(); - increaseIndent(); - for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { - if (i_2 !== 0) { - write(","); - writeLine(); - } - var e = entry.exportClause.elements[i_2]; - write("\""); - emitNodeWithCommentsAndWithoutSourcemap(e.name); - write("\": " + parameterName + "[\""); - emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); - write("\"]"); - } - decreaseIndent(); - writeLine(); - write("});"); - } - else { - writeLine(); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - break; - } - } - decreaseIndent(); - write("}"); - decreaseIndent(); - } - write("],"); - } - function emitExecute(node, startIndex) { - write("execute: function() {"); - increaseIndent(); - writeLine(); - for (var i = startIndex; i < node.statements.length; ++i) { - var statement = node.statements[i]; - switch (statement.kind) { - case 211: - case 220: - continue; - case 226: - if (!statement.moduleSpecifier) { - for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { - var element = _b[_a]; - emitExportSpecifierInSystemModule(element); - } - } - continue; - case 219: - if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { - continue; - } - default: - writeLine(); - emit(statement); - } - } - decreaseIndent(); - writeLine(); - write("}"); - } - function emitSystemModule(node, startIndex) { - collectExternalModuleInfo(node); - ts.Debug.assert(!exportFunctionForFile); - exportFunctionForFile = makeUniqueName("exports"); - writeLine(); - write("System.register("); - if (node.moduleName) { - write("\"" + node.moduleName + "\", "); - } - write("["); - var groupIndices = {}; - var dependencyGroups = []; - for (var i = 0; i < externalImports.length; ++i) { - var text = getExternalModuleNameText(externalImports[i]); - if (ts.hasProperty(groupIndices, text)) { - var groupIndex = groupIndices[text]; - dependencyGroups[groupIndex].push(externalImports[i]); - continue; - } - else { - groupIndices[text] = dependencyGroups.length; - dependencyGroups.push([externalImports[i]]); - } - if (i !== 0) { - write(", "); - } - write(text); - } - write("], function(" + exportFunctionForFile + ") {"); - writeLine(); - increaseIndent(); - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, dependencyGroups, startIndex); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitAMDDependencies(node, includeNonAmdDependencies) { - var aliasedModuleNames = []; - var unaliasedModuleNames = []; - var importAliasNames = []; - for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { - var amdDependency = _b[_a]; - if (amdDependency.name) { - aliasedModuleNames.push("\"" + amdDependency.path + "\""); - importAliasNames.push(amdDependency.name); - } - else { - unaliasedModuleNames.push("\"" + amdDependency.path + "\""); - } - } - for (var _c = 0; _c < externalImports.length; _c++) { - var importNode = externalImports[_c]; - var externalModuleName = getExternalModuleNameText(importNode); - var importAliasName = getLocalNameForExternalImport(importNode); - if (includeNonAmdDependencies && importAliasName) { - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(importAliasName); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - write("[\"require\", \"exports\""); - if (aliasedModuleNames.length) { - write(", "); - write(aliasedModuleNames.join(", ")); - } - if (unaliasedModuleNames.length) { - write(", "); - write(unaliasedModuleNames.join(", ")); - } - write("], function (require, exports"); - if (importAliasNames.length) { - write(", "); - write(importAliasNames.join(", ")); - } - } - function emitAMDModule(node, startIndex) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - writeLine(); - write("define("); - if (node.moduleName) { - write("\"" + node.moduleName + "\", "); - } - emitAMDDependencies(node, true); - write(") {"); - increaseIndent(); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitCommonJSModule(node, startIndex) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(false); - } - function emitUMDModule(node, startIndex) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); - emitAMDDependencies(node, false); - write(") {"); - increaseIndent(); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitES6Module(node, startIndex) { - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - } - function emitExportEquals(emitAsReturn) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { - writeLine(); - emitStart(exportEquals); - write(emitAsReturn ? "return " : "module.exports = "); - emit(exportEquals.expression); - write(";"); - emitEnd(exportEquals); - } - } - function emitJsxElement(node) { - switch (compilerOptions.jsx) { - case 2: - jsxEmitReact(node); - break; - case 1: - default: - jsxEmitPreserve(node); - break; - } - } - function trimReactWhitespaceAndApplyEntities(node) { - var result = undefined; - var text = ts.getTextOfNode(node, true); - var firstNonWhitespace = 0; - var lastNonWhitespace = -1; - for (var i = 0; i < text.length; i++) { - var c = text.charCodeAt(i); - if (ts.isLineBreak(c)) { - if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { - var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + "\" + ' ' + \"" : "") + part; - } - firstNonWhitespace = -1; - } - else if (!ts.isWhiteSpace(c)) { - lastNonWhitespace = i; - if (firstNonWhitespace === -1) { - firstNonWhitespace = i; - } - } - } - if (firstNonWhitespace !== -1) { - var part = text.substr(firstNonWhitespace); - result = (result ? result + "\" + ' ' + \"" : "") + part; - } - if (result) { - result = result.replace(/&(\w+);/g, function (s, m) { - if (entities[m] !== undefined) { - return String.fromCharCode(entities[m]); - } - else { - return s; - } - }); - } - return result; - } - function getTextToEmit(node) { - switch (compilerOptions.jsx) { - case 2: - var text = trimReactWhitespaceAndApplyEntities(node); - if (text === undefined || text.length === 0) { - return undefined; - } - else { - return text; - } - case 1: - default: - return ts.getTextOfNode(node, true); - } - } - function emitJsxText(node) { - switch (compilerOptions.jsx) { - case 2: - write("\""); - write(trimReactWhitespaceAndApplyEntities(node)); - write("\""); - break; - case 1: - default: - writer.writeLiteral(ts.getTextOfNode(node, true)); - break; - } - } - function emitJsxExpression(node) { - if (node.expression) { - switch (compilerOptions.jsx) { - case 1: - default: - write("{"); - emit(node.expression); - write("}"); - break; - case 2: - emit(node.expression); - break; - } - } - } - function emitDirectivePrologues(statements, startWithNewLine) { - for (var i = 0; i < statements.length; ++i) { - if (ts.isPrologueDirective(statements[i])) { - if (startWithNewLine || i > 0) { - writeLine(); - } - emit(statements[i]); - } - else { - return i; - } - } - return statements.length; - } - function writeLines(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 emitEmitHelpers(node) { - if (!compilerOptions.noEmitHelpers) { - if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { - writeLines(extendsHelper); - extendsEmitted = true; - } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16) { - writeLines(decorateHelper); - if (compilerOptions.emitDecoratorMetadata) { - writeLines(metadataHelper); - } - decorateEmitted = true; - } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32) { - writeLines(paramHelper); - paramEmitted = true; - } - if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64) { - writeLines(awaiterHelper); - awaiterEmitted = true; - } - } - } - function emitSourceFileNode(node) { - writeLine(); - emitShebang(); - emitDetachedComments(node); - var startIndex = emitDirectivePrologues(node.statements, false); - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - if (languageVersion >= 2) { - emitES6Module(node, startIndex); - } - else if (compilerOptions.module === 2) { - emitAMDModule(node, startIndex); - } - else if (compilerOptions.module === 4) { - emitSystemModule(node, startIndex); - } - else if (compilerOptions.module === 3) { - emitUMDModule(node, startIndex); - } - else { - emitCommonJSModule(node, startIndex); - } - } - else { - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - } - emitLeadingComments(node.endOfFileToken); - } - function emitNodeWithCommentsAndWithoutSourcemap(node) { - emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); - } - function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { - if (node) { - if (node.flags & 2) { - return emitCommentsOnNotEmittedNode(node); - } - if (isSpecializedCommentHandling(node)) { - return emitNodeWithoutSourceMap(node); - } - var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); - if (emitComments_1) { - emitLeadingComments(node); - } - emitNodeConsideringSourcemap(node); - if (emitComments_1) { - emitTrailingComments(node); - } - } - } - function emitNodeWithoutSourceMap(node) { - if (node) { - emitJavaScriptWorker(node); - } - } - function isSpecializedCommentHandling(node) { - switch (node.kind) { - case 213: - case 211: - case 220: - case 219: - case 214: - case 225: - return true; - } - } - function shouldEmitLeadingAndTrailingComments(node) { - switch (node.kind) { - case 191: - return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 216: - return shouldEmitModuleDeclaration(node); - case 215: - return shouldEmitEnumDeclaration(node); - } - ts.Debug.assert(!isSpecializedCommentHandling(node)); - if (node.kind !== 190 && - node.parent && - node.parent.kind === 172 && - node.parent.body === node && - compilerOptions.target <= 1) { - return false; - } - return true; - } - function emitJavaScriptWorker(node) { - switch (node.kind) { - case 67: - return emitIdentifier(node); - case 136: - return emitParameter(node); - case 141: - case 140: - return emitMethod(node); - case 143: - case 144: - return emitAccessor(node); - case 95: - return emitThis(node); - case 93: - return emitSuper(node); - case 91: - return write("null"); - case 97: - return write("true"); - case 82: - return write("false"); - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - return emitLiteral(node); - case 181: - return emitTemplateExpression(node); - case 188: - return emitTemplateSpan(node); - case 231: - case 232: - return emitJsxElement(node); - case 234: - return emitJsxText(node); - case 238: - return emitJsxExpression(node); - case 133: - return emitQualifiedName(node); - case 159: - return emitObjectBindingPattern(node); - case 160: - return emitArrayBindingPattern(node); - case 161: - return emitBindingElement(node); - case 162: - return emitArrayLiteral(node); - case 163: - return emitObjectLiteral(node); - case 243: - return emitPropertyAssignment(node); - case 244: - return emitShorthandPropertyAssignment(node); - case 134: - return emitComputedPropertyName(node); - case 164: - return emitPropertyAccess(node); - case 165: - return emitIndexedAccess(node); - case 166: - return emitCallExpression(node); - case 167: - return emitNewExpression(node); - case 168: - return emitTaggedTemplateExpression(node); - case 169: - return emit(node.expression); - case 187: - return emit(node.expression); - case 170: - return emitParenExpression(node); - case 211: - case 171: - case 172: - return emitFunctionDeclaration(node); - case 173: - return emitDeleteExpression(node); - case 174: - return emitTypeOfExpression(node); - case 175: - return emitVoidExpression(node); - case 176: - return emitAwaitExpression(node); - case 177: - return emitPrefixUnaryExpression(node); - case 178: - return emitPostfixUnaryExpression(node); - case 179: - return emitBinaryExpression(node); - case 180: - return emitConditionalExpression(node); - case 183: - return emitSpreadElementExpression(node); - case 182: - return emitYieldExpression(node); - case 185: - return; - case 190: - case 217: - return emitBlock(node); - case 191: - return emitVariableStatement(node); - case 192: - return write(";"); - case 193: - return emitExpressionStatement(node); - case 194: - return emitIfStatement(node); - case 195: - return emitDoStatement(node); - case 196: - return emitWhileStatement(node); - case 197: - return emitForStatement(node); - case 199: - case 198: - return emitForInOrForOfStatement(node); - case 200: - case 201: - return emitBreakOrContinueStatement(node); - case 202: - return emitReturnStatement(node); - case 203: - return emitWithStatement(node); - case 204: - return emitSwitchStatement(node); - case 239: - case 240: - return emitCaseOrDefaultClause(node); - case 205: - return emitLabelledStatement(node); - case 206: - return emitThrowStatement(node); - case 207: - return emitTryStatement(node); - case 242: - return emitCatchClause(node); - case 208: - return emitDebuggerStatement(node); - case 209: - return emitVariableDeclaration(node); - case 184: - return emitClassExpression(node); - case 212: - return emitClassDeclaration(node); - case 213: - return emitInterfaceDeclaration(node); - case 215: - return emitEnumDeclaration(node); - case 245: - return emitEnumMember(node); - case 216: - return emitModuleDeclaration(node); - case 220: - return emitImportDeclaration(node); - case 219: - return emitImportEqualsDeclaration(node); - case 226: - return emitExportDeclaration(node); - case 225: - return emitExportAssignment(node); - case 246: - return emitSourceFileNode(node); - } - } - function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; - } - function getLeadingCommentsWithoutDetachedComments() { - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); - if (detachedCommentsInfo.length - 1) { - detachedCommentsInfo.pop(); - } - else { - detachedCommentsInfo = undefined; - } - return leadingComments; - } - function isPinnedComments(comment) { - return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; - } - function isTripleSlashComment(comment) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 47) { - var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); - return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || - textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? - true : false; - } - return false; - } - function getLeadingCommentsToEmit(node) { - if (node.parent) { - if (node.parent.kind === 246 || node.pos !== node.parent.pos) { - if (hasDetachedComments(node.pos)) { - return getLeadingCommentsWithoutDetachedComments(); - } - else { - return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); - } - } - } - } - function getTrailingCommentsToEmit(node) { - if (node.parent) { - if (node.parent.kind === 246 || node.end !== node.parent.end) { - return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); - } - } - } - function emitCommentsOnNotEmittedNode(node) { - emitLeadingCommentsWorker(node, false); - } - function emitLeadingComments(node) { - return emitLeadingCommentsWorker(node, true); - } - function emitLeadingCommentsWorker(node, isEmittedNode) { - if (compilerOptions.removeComments) { - return; - } - var leadingComments; - if (isEmittedNode) { - leadingComments = getLeadingCommentsToEmit(node); - } - else { - if (node.pos === 0) { - leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); - } - } - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); - } - function emitTrailingComments(node) { - if (compilerOptions.removeComments) { - return; - } - var trailingComments = getTrailingCommentsToEmit(node); - ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); - } - function emitTrailingCommentsOfPosition(pos) { - if (compilerOptions.removeComments) { - return; - } - var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); - ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment); - } - function emitLeadingCommentsOfPositionWorker(pos) { - if (compilerOptions.removeComments) { - return; - } - var leadingComments; - if (hasDetachedComments(pos)) { - leadingComments = getLeadingCommentsWithoutDetachedComments(); - } - else { - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); - } - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); - } - function emitDetachedComments(node) { - var leadingComments; - if (compilerOptions.removeComments) { - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); - } - } - else { - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - } - if (leadingComments) { - var detachedComments = []; - var lastComment; - ts.forEach(leadingComments, function (comment) { - if (lastComment) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); - if (commentLine >= lastCommentLine + 2) { - return detachedComments; - } - } - detachedComments.push(comment); - lastComment = comment; - }); - if (detachedComments.length) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); - var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } - } - } - } - function emitShebang() { - var shebang = ts.getShebang(currentSourceFile.text); - if (shebang) { - write(shebang); - } - } - } - function emitFile(jsFilePath, sourceFile) { - emitJavaScript(jsFilePath, sourceFile); - if (compilerOptions.declaration) { - ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); - } - } - } - ts.emitFiles = emitFiles; var entities = { "quot": 0x0022, "amp": 0x0026, @@ -29323,6 +24298,5552 @@ var ts; "hearts": 0x2665, "diams": 0x2666 }; + function emitFiles(resolver, host, targetSourceFile) { + var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; + var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; + var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; + var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; + var compilerOptions = host.getCompilerOptions(); + var languageVersion = compilerOptions.target || 0; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; + var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; + var diagnostics = []; + var newLine = host.getNewLine(); + var jsxDesugaring = host.getCompilerOptions().jsx !== 1; + var shouldEmitJsx = function (s) { return (s.languageVariant === 1 && !jsxDesugaring); }; + if (targetSourceFile === undefined) { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); + emitFile(jsFilePath, sourceFile); + } + }); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); + } + } + else { + if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); + emitFile(jsFilePath, targetSourceFile); + } + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); + } + } + diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); + return { + emitSkipped: false, + 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 = ts.createTextWriter(newLine); + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; + var currentSourceFile; + var exportFunctionForFile; + var generatedNameSet = {}; + var nodeToGeneratedName = []; + var computedPropertyNamesToGeneratedNames; + var extendsEmitted = false; + var decorateEmitted = false; + var paramEmitted = false; + var awaiterEmitted = false; + var tempFlags = 0; + var tempVariables; + var tempParameters; + var externalImports; + var exportSpecifiers; + var exportEquals; + var hasExportStars; + var writeEmittedFiles = writeJavaScriptFile; + var detachedCommentsInfo; + var writeComment = ts.writeCommentRange; + var emit = emitNodeWithCommentsAndWithoutSourcemap; + var emitStart = function (node) { }; + var emitEnd = function (node) { }; + var emitToken = emitTokenText; + var scopeEmitStart = function (scopeDeclaration, scopeName) { }; + var scopeEmitEnd = function () { }; + var sourceMapData; + var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; + var moduleEmitDelegates = (_a = {}, + _a[5] = emitES6Module, + _a[2] = emitAMDModule, + _a[4] = emitSystemModule, + _a[3] = emitUMDModule, + _a[1] = emitCommonJSModule, + _a + ); + if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { + initializeEmitterWithSourceMaps(); + } + if (root) { + emitSourceFile(root); + } + else { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (!isExternalModuleOrDeclarationFile(sourceFile)) { + emitSourceFile(sourceFile); + } + }); + } + writeLine(); + writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); + return; + function emitSourceFile(sourceFile) { + currentSourceFile = sourceFile; + exportFunctionForFile = undefined; + emit(sourceFile); + } + function isUniqueName(name) { + return !resolver.hasGlobalName(name) && + !ts.hasProperty(currentSourceFile.identifiers, name) && + !ts.hasProperty(generatedNameSet, name); + } + function makeTempVariableName(flags) { + if (flags && !(tempFlags & flags)) { + var name_19 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_19)) { + tempFlags |= flags; + return name_19; + } + } + while (true) { + var count = tempFlags & 268435455; + tempFlags++; + if (count !== 8 && count !== 13) { + var name_20 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(name_20)) { + return name_20; + } + } + } + } + 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 generateNameForModuleOrEnum(node) { + var name = node.name.text; + return isUniqueLocalName(name, node) ? name : makeUniqueName(name); + } + function generateNameForImportOrExportDeclaration(node) { + var expr = ts.getExternalModuleName(node); + var baseName = expr.kind === 9 ? + ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; + return makeUniqueName(baseName); + } + function generateNameForExportDefault() { + return makeUniqueName("default"); + } + function generateNameForClassExpression() { + return makeUniqueName("class"); + } + function generateNameForNode(node) { + switch (node.kind) { + case 69: + return makeUniqueName(node.text); + case 218: + case 217: + return generateNameForModuleOrEnum(node); + case 222: + case 228: + return generateNameForImportOrExportDeclaration(node); + case 213: + case 214: + case 227: + return generateNameForExportDefault(); + case 186: + return generateNameForClassExpression(); + } + } + function getGeneratedNameForNode(node) { + var id = ts.getNodeId(node); + return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); + } + function initializeEmitterWithSourceMaps() { + var sourceMapDir; + var sourceMapSourceIndex = -1; + var sourceMapNameIndexMap = {}; + var sourceMapNameIndices = []; + function getSourceMapNameIndex() { + return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; + } + var lastRecordedSourceMapSpan; + var lastEncodedSourceMapSpan = { + emittedLine: 1, + emittedColumn: 1, + sourceLine: 1, + sourceColumn: 1, + sourceIndex: 0 + }; + var lastEncodedNameIndex = 0; + function encodeLastRecordedSourceMapSpan() { + if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { + return; + } + var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; + if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { + if (sourceMapData.sourceMapMappings) { + sourceMapData.sourceMapMappings += ","; + } + } + else { + for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { + sourceMapData.sourceMapMappings += ";"; + } + prevEncodedEmittedColumn = 1; + } + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); + if (lastRecordedSourceMapSpan.nameIndex >= 0) { + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); + lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; + } + lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; + sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); + function base64VLQFormatEncode(inValue) { + function base64FormatEncode(inValue) { + if (inValue < 64) { + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); + } + throw TypeError(inValue + ": not a 64 based value"); + } + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } + else { + inValue = inValue << 1; + } + var encodedStr = ""; + do { + var currentDigit = inValue & 31; + inValue = inValue >> 5; + if (inValue > 0) { + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + base64FormatEncode(currentDigit); + } while (inValue > 0); + return encodedStr; + } + } + function recordSourceMapSpan(pos) { + var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); + sourceLinePos.line++; + sourceLinePos.character++; + var emittedLine = writer.getLine(); + var emittedColumn = writer.getColumn(); + if (!lastRecordedSourceMapSpan || + lastRecordedSourceMapSpan.emittedLine !== emittedLine || + lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || + (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && + (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || + (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { + encodeLastRecordedSourceMapSpan(); + lastRecordedSourceMapSpan = { + emittedLine: emittedLine, + emittedColumn: emittedColumn, + sourceLine: sourceLinePos.line, + sourceColumn: sourceLinePos.character, + nameIndex: getSourceMapNameIndex(), + sourceIndex: sourceMapSourceIndex + }; + } + else { + lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; + lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; + lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; + } + } + function recordEmitNodeStartSpan(node) { + recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); + } + function recordEmitNodeEndSpan(node) { + recordSourceMapSpan(node.end); + } + function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { + var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); + recordSourceMapSpan(tokenStartPos); + var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); + recordSourceMapSpan(tokenEndPos); + return tokenEndPos; + } + function recordNewSourceFileStart(node) { + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true)); + sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; + sourceMapData.inputSourceFileNames.push(node.fileName); + if (compilerOptions.inlineSources) { + if (!sourceMapData.sourceMapSourcesContent) { + sourceMapData.sourceMapSourcesContent = []; + } + sourceMapData.sourceMapSourcesContent.push(node.text); + } + } + function recordScopeNameOfNode(node, scopeName) { + function recordScopeNameIndex(scopeNameIndex) { + sourceMapNameIndices.push(scopeNameIndex); + } + function recordScopeNameStart(scopeName) { + var scopeNameIndex = -1; + if (scopeName) { + var parentIndex = getSourceMapNameIndex(); + if (parentIndex !== -1) { + var name_21 = node.name; + if (!name_21 || name_21.kind !== 136) { + scopeName = "." + scopeName; + } + scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; + } + scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); + if (scopeNameIndex === undefined) { + scopeNameIndex = sourceMapData.sourceMapNames.length; + sourceMapData.sourceMapNames.push(scopeName); + sourceMapNameIndexMap[scopeName] = scopeNameIndex; + } + } + recordScopeNameIndex(scopeNameIndex); + } + if (scopeName) { + recordScopeNameStart(scopeName); + } + else if (node.kind === 213 || + node.kind === 173 || + node.kind === 143 || + node.kind === 142 || + node.kind === 145 || + node.kind === 146 || + node.kind === 218 || + node.kind === 214 || + node.kind === 217) { + if (node.name) { + var name_22 = node.name; + scopeName = name_22.kind === 136 + ? ts.getTextOfNode(name_22) + : node.name.text; + } + recordScopeNameStart(scopeName); + } + else { + recordScopeNameIndex(getSourceMapNameIndex()); + } + } + function recordScopeNameEnd() { + sourceMapNameIndices.pop(); + } + ; + function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { + recordSourceMapSpan(comment.pos); + ts.writeCommentRange(currentSourceFile, writer, comment, newLine); + recordSourceMapSpan(comment.end); + } + function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { + if (typeof JSON !== "undefined") { + var map_1 = { + version: version, + file: file, + sourceRoot: sourceRoot, + sources: sources, + names: names, + mappings: mappings + }; + if (sourcesContent !== undefined) { + map_1.sourcesContent = sourcesContent; + } + return JSON.stringify(map_1); + } + return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; + function serializeStringArray(list) { + var output = ""; + for (var i = 0, n = list.length; i < n; i++) { + if (i) { + output += ","; + } + output += "\"" + ts.escapeString(list[i]) + "\""; + } + return output; + } + } + function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { + encodeLastRecordedSourceMapSpan(); + var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); + sourceMapDataList.push(sourceMapData); + var sourceMapUrl; + if (compilerOptions.inlineSourceMap) { + var base64SourceMapText = ts.convertToBase64(sourceMapText); + sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; + } + else { + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); + sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; + } + writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); + } + var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); + sourceMapData = { + sourceMapFilePath: jsFilePath + ".map", + jsSourceMappingURL: sourceMapJsFile + ".map", + sourceMapFile: sourceMapJsFile, + sourceMapSourceRoot: compilerOptions.sourceRoot || "", + sourceMapSources: [], + inputSourceFileNames: [], + sourceMapNames: [], + sourceMapMappings: "", + sourceMapSourcesContent: undefined, + sourceMapDecodedMappings: [] + }; + sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); + if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47) { + sourceMapData.sourceMapSourceRoot += ts.directorySeparator; + } + if (compilerOptions.mapRoot) { + sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); + if (root) { + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); + } + if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), host.getCurrentDirectory(), host.getCanonicalFileName, true); + } + else { + sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); + } + } + else { + sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); + } + function emitNodeWithSourceMap(node) { + if (node) { + if (ts.nodeIsSynthesized(node)) { + return emitNodeWithoutSourceMap(node); + } + if (node.kind !== 248) { + recordEmitNodeStartSpan(node); + emitNodeWithoutSourceMap(node); + recordEmitNodeEndSpan(node); + } + else { + recordNewSourceFileStart(node); + emitNodeWithoutSourceMap(node); + } + } + } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } + writeEmittedFiles = writeJavaScriptAndSourceMapFile; + emit = emitNodeWithCommentsAndWithSourcemap; + emitStart = recordEmitNodeStartSpan; + emitEnd = recordEmitNodeEndSpan; + emitToken = writeTextWithSpanRecord; + scopeEmitStart = recordScopeNameOfNode; + scopeEmitEnd = recordScopeNameEnd; + writeComment = writeCommentRangeWithMap; + } + function writeJavaScriptFile(emitOutput, writeByteOrderMark) { + ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); + } + function createTempVariable(flags) { + var result = ts.createSynthesizedNode(69); + result.text = makeTempVariableName(flags); + return result; + } + function recordTempDeclaration(name) { + if (!tempVariables) { + tempVariables = []; + } + tempVariables.push(name); + } + function createAndRecordTempVariable(flags) { + var temp = createTempVariable(flags); + recordTempDeclaration(temp); + return temp; + } + function emitTempDeclarations(newLine) { + if (tempVariables) { + if (newLine) { + writeLine(); + } + else { + write(" "); + } + write("var "); + emitCommaList(tempVariables); + write(";"); + } + } + function emitTokenText(tokenKind, startPos, emitFn) { + var tokenString = ts.tokenToString(tokenKind); + if (emitFn) { + emitFn(); + } + else { + write(tokenString); + } + return startPos + tokenString.length; + } + function emitOptional(prefix, node) { + if (node) { + write(prefix); + emit(node); + } + } + function emitParenthesizedIf(node, parenthesized) { + if (parenthesized) { + write("("); + } + emit(node); + if (parenthesized) { + write(")"); + } + } + function emitTrailingCommaIfPresent(nodeList) { + if (nodeList.hasTrailingComma) { + write(","); + } + } + function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { + ts.Debug.assert(nodes.length > 0); + increaseIndent(); + if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + for (var i = 0, n = nodes.length; i < n; i++) { + if (i) { + if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { + write(", "); + } + else { + write(","); + writeLine(); + } + } + emit(nodes[i]); + } + if (nodes.hasTrailingComma && allowTrailingComma) { + write(","); + } + decreaseIndent(); + if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + } + function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { + if (!emitNode) { + emitNode = emit; + } + for (var i = 0; i < count; i++) { + if (multiLine) { + if (i || leadingComma) { + write(","); + } + writeLine(); + } + else { + if (i || leadingComma) { + write(", "); + } + } + var node = nodes[start + i]; + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); + leadingComma = true; + } + if (trailingComma) { + write(","); + } + if (multiLine && !noTrailingNewLine) { + writeLine(); + } + return count; + } + function emitCommaList(nodes) { + if (nodes) { + emitList(nodes, 0, nodes.length, false, false); + } + } + function emitLines(nodes) { + emitLinesStartingAt(nodes, 0); + } + function emitLinesStartingAt(nodes, startIndex) { + for (var i = startIndex; i < nodes.length; i++) { + writeLine(); + emit(nodes[i]); + } + } + function isBinaryOrOctalIntegerLiteral(node, text) { + if (node.kind === 8 && text.length > 1) { + switch (text.charCodeAt(1)) { + case 98: + case 66: + case 111: + case 79: + return true; + } + } + return false; + } + function emitLiteral(node) { + var text = getLiteralText(node); + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { + writer.writeLiteral(text); + } + else if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { + write(node.text); + } + else { + write(text); + } + } + function getLiteralText(node) { + if (languageVersion < 2 && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { + return getQuotedEscapedLiteralText("\"", node.text, "\""); + } + if (node.parent) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + } + switch (node.kind) { + case 9: + return getQuotedEscapedLiteralText("\"", node.text, "\""); + case 11: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 12: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 13: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8: + return node.text; + } + ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + } + function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { + return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; + } + function emitDownlevelRawTemplateLiteral(node) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + var isLast = node.kind === 11 || node.kind === 14; + text = text.substring(1, text.length - (isLast ? 1 : 2)); + text = text.replace(/\r\n?/g, "\n"); + text = ts.escapeString(text); + write("\"" + text + "\""); + } + function emitDownlevelTaggedTemplateArray(node, literalEmitter) { + write("["); + if (node.template.kind === 11) { + literalEmitter(node.template); + } + else { + literalEmitter(node.template.head); + ts.forEach(node.template.templateSpans, function (child) { + write(", "); + literalEmitter(child.literal); + }); + } + write("]"); + } + function emitDownlevelTaggedTemplate(node) { + var tempVariable = createAndRecordTempVariable(0); + write("("); + emit(tempVariable); + write(" = "); + emitDownlevelTaggedTemplateArray(node, emit); + write(", "); + emit(tempVariable); + write(".raw = "); + emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); + write(", "); + emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); + write("("); + emit(tempVariable); + if (node.template.kind === 183) { + ts.forEach(node.template.templateSpans, function (templateSpan) { + write(", "); + var needsParens = templateSpan.expression.kind === 181 + && templateSpan.expression.operatorToken.kind === 24; + emitParenthesizedIf(templateSpan.expression, needsParens); + }); + } + write("))"); + } + function emitTemplateExpression(node) { + if (languageVersion >= 2) { + ts.forEachChild(node, emit); + return; + } + var emitOuterParens = ts.isExpression(node.parent) + && templateNeedsParens(node, node.parent); + if (emitOuterParens) { + write("("); + } + var headEmitted = false; + if (shouldEmitTemplateHead()) { + emitLiteral(node.head); + headEmitted = true; + } + for (var i = 0, n = node.templateSpans.length; i < n; i++) { + var templateSpan = node.templateSpans[i]; + var needsParens = templateSpan.expression.kind !== 172 + && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; + if (i > 0 || headEmitted) { + write(" + "); + } + emitParenthesizedIf(templateSpan.expression, needsParens); + if (templateSpan.literal.text.length !== 0) { + write(" + "); + emitLiteral(templateSpan.literal); + } + } + if (emitOuterParens) { + write(")"); + } + function shouldEmitTemplateHead() { + 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 168: + case 169: + return parent.expression === template; + case 170: + case 172: + return false; + default: + return comparePrecedenceToBinaryPlus(parent) !== -1; + } + } + function comparePrecedenceToBinaryPlus(expression) { + switch (expression.kind) { + case 181: + switch (expression.operatorToken.kind) { + case 37: + case 39: + case 40: + return 1; + case 35: + case 36: + return 0; + default: + return -1; + } + case 184: + case 182: + return -1; + default: + return 1; + } + } + } + function emitTemplateSpan(span) { + emit(span.expression); + emit(span.literal); + } + function jsxEmitReact(node) { + function emitTagName(name) { + if (name.kind === 69 && ts.isIntrinsicJsxName(name.text)) { + write("\""); + emit(name); + write("\""); + } + else { + emit(name); + } + } + function emitAttributeName(name) { + if (/[A-Za-z_]+[\w*]/.test(name.text)) { + write("\""); + emit(name); + write("\""); + } + else { + emit(name); + } + } + function emitJsxAttribute(node) { + emitAttributeName(node.name); + write(": "); + if (node.initializer) { + emit(node.initializer); + } + else { + write("true"); + } + } + function emitJsxElement(openingNode, children) { + var syntheticReactRef = ts.createSynthesizedNode(69); + syntheticReactRef.text = "React"; + syntheticReactRef.parent = openingNode; + emitLeadingComments(openingNode); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); + emitTagName(openingNode.tagName); + write(", "); + if (openingNode.attributes.length === 0) { + write("null"); + } + else { + var attrs = openingNode.attributes; + if (ts.forEach(attrs, function (attr) { return attr.kind === 239; })) { + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); + var haveOpenedObjectLiteral = false; + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 239) { + if (i_1 === 0) { + write("{}, "); + } + if (haveOpenedObjectLiteral) { + write("}"); + haveOpenedObjectLiteral = false; + } + if (i_1 > 0) { + write(", "); + } + emit(attrs[i_1].expression); + } + else { + ts.Debug.assert(attrs[i_1].kind === 238); + if (haveOpenedObjectLiteral) { + write(", "); + } + else { + haveOpenedObjectLiteral = true; + if (i_1 > 0) { + write(", "); + } + write("{"); + } + emitJsxAttribute(attrs[i_1]); + } + } + if (haveOpenedObjectLiteral) + write("}"); + write(")"); + } + else { + write("{"); + for (var i = 0; i < attrs.length; i++) { + if (i > 0) { + write(", "); + } + emitJsxAttribute(attrs[i]); + } + write("}"); + } + } + if (children) { + for (var i = 0; i < children.length; i++) { + if (children[i].kind === 240 && !(children[i].expression)) { + continue; + } + if (children[i].kind === 236) { + var text = getTextToEmit(children[i]); + if (text !== undefined) { + write(", \""); + write(text); + write("\""); + } + } + else { + write(", "); + emit(children[i]); + } + } + } + write(")"); + emitTrailingComments(openingNode); + } + if (node.kind === 233) { + emitJsxElement(node.openingElement, node.children); + } + else { + ts.Debug.assert(node.kind === 234); + emitJsxElement(node); + } + } + function jsxEmitPreserve(node) { + function emitJsxAttribute(node) { + emit(node.name); + if (node.initializer) { + write("="); + emit(node.initializer); + } + } + function emitJsxSpreadAttribute(node) { + write("{..."); + emit(node.expression); + write("}"); + } + function emitAttributes(attribs) { + for (var i = 0, n = attribs.length; i < n; i++) { + if (i > 0) { + write(" "); + } + if (attribs[i].kind === 239) { + emitJsxSpreadAttribute(attribs[i]); + } + else { + ts.Debug.assert(attribs[i].kind === 238); + emitJsxAttribute(attribs[i]); + } + } + } + function emitJsxOpeningOrSelfClosingElement(node) { + write("<"); + emit(node.tagName); + if (node.attributes.length > 0 || (node.kind === 234)) { + write(" "); + } + emitAttributes(node.attributes); + if (node.kind === 234) { + write("/>"); + } + else { + write(">"); + } + } + function emitJsxClosingElement(node) { + write(""); + } + function emitJsxElement(node) { + emitJsxOpeningOrSelfClosingElement(node.openingElement); + for (var i = 0, n = node.children.length; i < n; i++) { + emit(node.children[i]); + } + emitJsxClosingElement(node.closingElement); + } + if (node.kind === 233) { + emitJsxElement(node); + } + else { + ts.Debug.assert(node.kind === 234); + emitJsxOpeningOrSelfClosingElement(node); + } + } + function emitExpressionForPropertyName(node) { + ts.Debug.assert(node.kind !== 163); + if (node.kind === 9) { + emitLiteral(node); + } + else if (node.kind === 136) { + if (ts.nodeIsDecorated(node.parent)) { + if (!computedPropertyNamesToGeneratedNames) { + computedPropertyNamesToGeneratedNames = []; + } + var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; + if (generatedName) { + write(generatedName); + return; + } + generatedName = createAndRecordTempVariable(0).text; + computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; + write(generatedName); + write(" = "); + } + emit(node.expression); + } + else { + write("\""); + if (node.kind === 8) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + write("\""); + } + } + function isExpressionIdentifier(node) { + var parent = node.parent; + switch (parent.kind) { + case 164: + case 189: + case 181: + case 168: + case 241: + case 136: + case 182: + case 139: + case 175: + case 197: + case 167: + case 227: + case 195: + case 188: + case 199: + case 200: + case 201: + case 196: + case 234: + case 235: + case 239: + case 240: + case 169: + case 172: + case 180: + case 179: + case 204: + case 246: + case 185: + case 206: + case 170: + case 190: + case 208: + case 171: + case 176: + case 177: + case 198: + case 205: + case 184: + return true; + case 163: + case 247: + case 138: + case 245: + case 141: + case 211: + return parent.initializer === node; + case 166: + return parent.expression === node; + case 174: + case 173: + return parent.body === node; + case 221: + return parent.moduleReference === node; + case 135: + return parent.left === node; + } + return false; + } + function emitExpressionIdentifier(node) { + if (resolver.getNodeCheckFlags(node) & 2048) { + write("_arguments"); + return; + } + var container = resolver.getReferencedExportContainer(node); + if (container) { + if (container.kind === 248) { + if (modulekind !== 5 && modulekind !== 4) { + write("exports."); + } + } + else { + write(getGeneratedNameForNode(container)); + write("."); + } + } + else if (modulekind !== 5) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (declaration.kind === 223) { + write(getGeneratedNameForNode(declaration.parent)); + write(languageVersion === 0 ? "[\"default\"]" : ".default"); + return; + } + else if (declaration.kind === 226) { + write(getGeneratedNameForNode(declaration.parent.parent.parent)); + var name_23 = declaration.propertyName || declaration.name; + var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name_23); + if (languageVersion === 0 && identifier === "default") { + write("[\"default\"]"); + } + else { + write("."); + write(identifier); + } + return; + } + } + declaration = resolver.getReferencedNestedRedeclaration(node); + if (declaration) { + write(getGeneratedNameForNode(declaration.name)); + return; + } + } + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function isNameOfNestedRedeclaration(node) { + if (languageVersion < 2) { + var parent_6 = node.parent; + switch (parent_6.kind) { + case 163: + case 214: + case 217: + case 211: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); + } + } + return false; + } + function emitIdentifier(node) { + if (!node.parent) { + write(node.text); + } + else if (isExpressionIdentifier(node)) { + emitExpressionIdentifier(node); + } + else if (isNameOfNestedRedeclaration(node)) { + write(getGeneratedNameForNode(node)); + } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function emitThis(node) { + if (resolver.getNodeCheckFlags(node) & 2) { + write("_this"); + } + else { + write("this"); + } + } + function emitSuper(node) { + if (languageVersion >= 2) { + write("super"); + } + else { + var flags = resolver.getNodeCheckFlags(node); + if (flags & 256) { + write("_super.prototype"); + } + else { + write("_super"); + } + } + } + function emitObjectBindingPattern(node) { + write("{ "); + var elements = node.elements; + emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + write(" }"); + } + function emitArrayBindingPattern(node) { + write("["); + var elements = node.elements; + emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + write("]"); + } + function emitBindingElement(node) { + if (node.propertyName) { + emit(node.propertyName); + write(": "); + } + if (node.dotDotDotToken) { + write("..."); + } + if (ts.isBindingPattern(node.name)) { + emit(node.name); + } + else { + emitModuleMemberName(node); + } + emitOptional(" = ", node.initializer); + } + function emitSpreadElementExpression(node) { + write("..."); + emit(node.expression); + } + function emitYieldExpression(node) { + write(ts.tokenToString(114)); + if (node.asteriskToken) { + write("*"); + } + if (node.expression) { + write(" "); + emit(node.expression); + } + } + function emitAwaitExpression(node) { + var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); + if (needsParenthesis) { + write("("); + } + write(ts.tokenToString(114)); + write(" "); + emit(node.expression); + if (needsParenthesis) { + write(")"); + } + } + function needsParenthesisForAwaitExpressionAsYield(node) { + if (node.parent.kind === 181 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + return true; + } + else if (node.parent.kind === 182 && node.parent.condition === node) { + return true; + } + return false; + } + function needsParenthesisForPropertyAccessOrInvocation(node) { + switch (node.kind) { + case 69: + case 164: + case 166: + case 167: + case 168: + case 172: + return false; + } + return true; + } + function emitListWithSpread(elements, needsUniqueCopy, multiLine, trailingComma, useConcat) { + var pos = 0; + var group = 0; + var length = elements.length; + while (pos < length) { + if (group === 1 && useConcat) { + write(".concat("); + } + else if (group > 0) { + write(", "); + } + var e = elements[pos]; + if (e.kind === 185) { + e = e.expression; + emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); + pos++; + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 164) { + write(".slice()"); + } + } + else { + var i = pos; + while (i < length && elements[i].kind !== 185) { + i++; + } + write("["); + if (multiLine) { + increaseIndent(); + } + emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); + if (multiLine) { + decreaseIndent(); + } + write("]"); + pos = i; + } + group++; + } + if (group > 1) { + if (useConcat) { + write(")"); + } + } + } + function isSpreadElementExpression(node) { + return node.kind === 185; + } + function emitArrayLiteral(node) { + var elements = node.elements; + if (elements.length === 0) { + write("[]"); + } + else if (languageVersion >= 2 || !ts.forEach(elements, isSpreadElementExpression)) { + write("["); + emitLinePreservingList(node, node.elements, elements.hasTrailingComma, false); + write("]"); + } + else { + emitListWithSpread(elements, true, (node.flags & 2048) !== 0, elements.hasTrailingComma, true); + } + } + function emitObjectLiteralBody(node, numElements) { + if (numElements === 0) { + write("{}"); + return; + } + write("{"); + if (numElements > 0) { + var properties = node.properties; + if (numElements === properties.length) { + emitLinePreservingList(node, properties, languageVersion >= 1, true); + } + else { + var multiLine = (node.flags & 2048) !== 0; + if (!multiLine) { + write(" "); + } + else { + increaseIndent(); + } + emitList(properties, 0, numElements, multiLine, false); + if (!multiLine) { + write(" "); + } + else { + decreaseIndent(); + } + } + } + write("}"); + } + function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { + var multiLine = (node.flags & 2048) !== 0; + var properties = node.properties; + write("("); + if (multiLine) { + increaseIndent(); + } + var tempVar = createAndRecordTempVariable(0); + emit(tempVar); + write(" = "); + emitObjectLiteralBody(node, firstComputedPropertyIndex); + for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { + writeComma(); + var property = properties[i]; + emitStart(property); + if (property.kind === 145 || property.kind === 146) { + var accessors = ts.getAllAccessorDeclarations(node.properties, property); + if (property !== accessors.firstAccessor) { + continue; + } + write("Object.defineProperty("); + emit(tempVar); + write(", "); + emitStart(node.name); + emitExpressionForPropertyName(property.name); + emitEnd(property.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("})"); + emitEnd(property); + } + else { + emitLeadingComments(property); + emitStart(property.name); + emit(tempVar); + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + if (property.kind === 245) { + emit(property.initializer); + } + else if (property.kind === 246) { + emitExpressionIdentifier(property.name); + } + else if (property.kind === 143) { + emitFunctionDeclaration(property); + } + else { + ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); + } + } + emitEnd(property); + } + writeComma(); + emit(tempVar); + if (multiLine) { + decreaseIndent(); + writeLine(); + } + write(")"); + function writeComma() { + if (multiLine) { + write(","); + writeLine(); + } + else { + write(", "); + } + } + } + function emitObjectLiteral(node) { + var properties = node.properties; + if (languageVersion < 2) { + var numProperties = properties.length; + var numInitialNonComputedProperties = numProperties; + for (var i = 0, n = properties.length; i < n; i++) { + if (properties[i].name.kind === 136) { + numInitialNonComputedProperties = i; + break; + } + } + var hasComputedProperty = numInitialNonComputedProperties !== properties.length; + if (hasComputedProperty) { + emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); + return; + } + } + emitObjectLiteralBody(node, properties.length); + } + function createBinaryExpression(left, operator, right, startsOnNewLine) { + var result = ts.createSynthesizedNode(181, startsOnNewLine); + result.operatorToken = ts.createSynthesizedNode(operator); + result.left = left; + result.right = right; + return result; + } + function createPropertyAccessExpression(expression, name) { + var result = ts.createSynthesizedNode(166); + result.expression = parenthesizeForAccess(expression); + result.dotToken = ts.createSynthesizedNode(21); + result.name = name; + return result; + } + function createElementAccessExpression(expression, argumentExpression) { + var result = ts.createSynthesizedNode(167); + result.expression = parenthesizeForAccess(expression); + result.argumentExpression = argumentExpression; + return result; + } + function parenthesizeForAccess(expr) { + while (expr.kind === 171 || expr.kind === 189) { + expr = expr.expression; + } + if (ts.isLeftHandSideExpression(expr) && + expr.kind !== 169 && + expr.kind !== 8) { + return expr; + } + var node = ts.createSynthesizedNode(172); + node.expression = expr; + return node; + } + function emitComputedPropertyName(node) { + write("["); + emitExpressionForPropertyName(node); + write("]"); + } + function emitMethod(node) { + if (languageVersion >= 2 && node.asteriskToken) { + write("*"); + } + emit(node.name); + if (languageVersion < 2) { + write(": function "); + } + emitSignatureAndBody(node); + } + function emitPropertyAssignment(node) { + emit(node.name); + write(": "); + emitTrailingCommentsOfPosition(node.initializer.pos); + emit(node.initializer); + } + function isNamespaceExportReference(node) { + var container = resolver.getReferencedExportContainer(node); + return container && container.kind !== 248; + } + function emitShorthandPropertyAssignment(node) { + writeTextOfNode(currentSourceFile, node.name); + if (languageVersion < 2 || isNamespaceExportReference(node.name)) { + write(": "); + emit(node.name); + } + if (languageVersion >= 2 && node.objectAssignmentInitializer) { + write(" = "); + emit(node.objectAssignmentInitializer); + } + } + function tryEmitConstantValue(node) { + var constantValue = tryGetConstEnumValue(node); + if (constantValue !== undefined) { + write(constantValue.toString()); + if (!compilerOptions.removeComments) { + var propertyName = node.kind === 166 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + write(" /* " + propertyName + " */"); + } + return true; + } + return false; + } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 166 || node.kind === 167 + ? resolver.getConstantValue(node) + : undefined; + } + function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { + var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); + var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); + if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { + increaseIndent(); + writeLine(); + return true; + } + else { + if (valueToWriteWhenNotIndenting) { + write(valueToWriteWhenNotIndenting); + } + return false; + } + } + function emitPropertyAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); + var shouldEmitSpace; + if (!indentedBeforeDot) { + if (node.expression.kind === 8) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21)) < 0; + } + else { + var constantValue = tryGetConstEnumValue(node.expression); + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } + } + if (shouldEmitSpace) { + write(" ."); + } + else { + write("."); + } + var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); + emit(node.name); + decreaseIndentIf(indentedBeforeDot, indentedAfterDot); + } + function emitQualifiedName(node) { + emit(node.left); + write("."); + emit(node.right); + } + function emitQualifiedNameAsExpression(node, useFallback) { + if (node.left.kind === 69) { + emitEntityNameAsExpression(node.left, useFallback); + } + else if (useFallback) { + var temp = createAndRecordTempVariable(0); + write("("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(node.left, true); + write(") && "); + emitNodeWithoutSourceMap(temp); + } + else { + emitEntityNameAsExpression(node.left, false); + } + write("."); + emit(node.right); + } + function emitEntityNameAsExpression(node, useFallback) { + switch (node.kind) { + case 69: + if (useFallback) { + write("typeof "); + emitExpressionIdentifier(node); + write(" !== 'undefined' && "); + } + emitExpressionIdentifier(node); + break; + case 135: + emitQualifiedNameAsExpression(node, useFallback); + break; + } + } + function emitIndexedAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + write("["); + emit(node.argumentExpression); + write("]"); + } + function hasSpreadElement(elements) { + return ts.forEach(elements, function (e) { return e.kind === 185; }); + } + function skipParentheses(node) { + while (node.kind === 172 || node.kind === 171 || node.kind === 189) { + node = node.expression; + } + return node; + } + function emitCallTarget(node) { + if (node.kind === 69 || node.kind === 97 || node.kind === 95) { + emit(node); + return node; + } + var temp = createAndRecordTempVariable(0); + write("("); + emit(temp); + write(" = "); + emit(node); + write(")"); + return temp; + } + function emitCallWithSpread(node) { + var target; + var expr = skipParentheses(node.expression); + if (expr.kind === 166) { + target = emitCallTarget(expr.expression); + write("."); + emit(expr.name); + } + else if (expr.kind === 167) { + target = emitCallTarget(expr.expression); + write("["); + emit(expr.argumentExpression); + write("]"); + } + else if (expr.kind === 95) { + target = expr; + write("_super"); + } + else { + emit(node.expression); + } + write(".apply("); + if (target) { + if (target.kind === 95) { + emitThis(target); + } + else { + emit(target); + } + } + else { + write("void 0"); + } + write(", "); + emitListWithSpread(node.arguments, false, false, false, true); + write(")"); + } + function emitCallExpression(node) { + if (languageVersion < 2 && hasSpreadElement(node.arguments)) { + emitCallWithSpread(node); + return; + } + var superCall = false; + if (node.expression.kind === 95) { + emitSuper(node.expression); + superCall = true; + } + else { + emit(node.expression); + superCall = node.expression.kind === 166 && node.expression.expression.kind === 95; + } + if (superCall && languageVersion < 2) { + write(".call("); + emitThis(node.expression); + if (node.arguments.length) { + write(", "); + emitCommaList(node.arguments); + } + write(")"); + } + else { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + function emitNewExpression(node) { + write("new "); + if (languageVersion === 1 && + node.arguments && + hasSpreadElement(node.arguments)) { + write("("); + var target = emitCallTarget(node.expression); + write(".bind.apply("); + emit(target); + write(", [void 0].concat("); + emitListWithSpread(node.arguments, false, false, false, false); + write(")))"); + write("()"); + } + else { + emit(node.expression); + if (node.arguments) { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + } + function emitTaggedTemplateExpression(node) { + if (languageVersion >= 2) { + emit(node.tag); + write(" "); + emit(node.template); + } + else { + emitDownlevelTaggedTemplate(node); + } + } + function emitParenExpression(node) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 174) { + if (node.expression.kind === 171 || node.expression.kind === 189) { + var operand = node.expression.expression; + while (operand.kind === 171 || operand.kind === 189) { + operand = operand.expression; + } + if (operand.kind !== 179 && + operand.kind !== 177 && + operand.kind !== 176 && + operand.kind !== 175 && + operand.kind !== 180 && + operand.kind !== 169 && + !(operand.kind === 168 && node.parent.kind === 169) && + !(operand.kind === 173 && node.parent.kind === 168) && + !(operand.kind === 8 && node.parent.kind === 166)) { + emit(operand); + return; + } + } + } + write("("); + emit(node.expression); + write(")"); + } + function emitDeleteExpression(node) { + write(ts.tokenToString(78)); + write(" "); + emit(node.expression); + } + function emitVoidExpression(node) { + write(ts.tokenToString(103)); + write(" "); + emit(node.expression); + } + function emitTypeOfExpression(node) { + write(ts.tokenToString(101)); + write(" "); + emit(node.expression); + } + function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 69 || ts.nodeIsSynthesized(node)) { + return false; + } + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 211 || node.parent.kind === 163); + var targetDeclaration = isVariableDeclarationOrBindingElement + ? node.parent + : resolver.getReferencedValueDeclaration(node); + return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); + } + function emitPrefixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + } + write(ts.tokenToString(node.operator)); + if (node.operand.kind === 179) { + var operand = node.operand; + if (node.operator === 35 && (operand.operator === 35 || operand.operator === 41)) { + write(" "); + } + else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) { + write(" "); + } + } + emit(node.operand); + if (exportChanged) { + write(")"); + } + } + function emitPostfixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + write("(" + exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + write(ts.tokenToString(node.operator)); + emit(node.operand); + if (node.operator === 41) { + write(") - 1)"); + } + else { + write(") + 1)"); + } + } + else { + emit(node.operand); + write(ts.tokenToString(node.operator)); + } + } + function shouldHoistDeclarationInSystemJsModule(node) { + return isSourceFileLevelDeclarationInSystemJsModule(node, false); + } + function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { + if (!node || languageVersion >= 2 || !isCurrentFileSystemExternalModule()) { + return false; + } + var current = node; + while (current) { + if (current.kind === 248) { + return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); + } + else if (ts.isFunctionLike(current) || current.kind === 219) { + return false; + } + else { + current = current.parent; + } + } + } + function emitExponentiationOperator(node) { + var leftHandSideExpression = node.left; + if (node.operatorToken.kind === 60) { + var synthesizedLHS; + var shouldEmitParentheses = false; + if (ts.isElementAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(167, false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); + synthesizedLHS.expression = identifier; + if (leftHandSideExpression.argumentExpression.kind !== 8 && + leftHandSideExpression.argumentExpression.kind !== 9) { + var tempArgumentExpression = createAndRecordTempVariable(268435456); + synthesizedLHS.argumentExpression = tempArgumentExpression; + emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, true); + } + else { + synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; + } + write(", "); + } + else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(166, false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); + synthesizedLHS.expression = identifier; + synthesizedLHS.dotToken = leftHandSideExpression.dotToken; + synthesizedLHS.name = leftHandSideExpression.name; + write(", "); + } + emit(synthesizedLHS || leftHandSideExpression); + write(" = "); + write("Math.pow("); + emit(synthesizedLHS || leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + if (shouldEmitParentheses) { + write(")"); + } + } + else { + write("Math.pow("); + emit(leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + } + } + function emitBinaryExpression(node) { + if (languageVersion < 2 && node.operatorToken.kind === 56 && + (node.left.kind === 165 || node.left.kind === 164)) { + emitDestructuring(node, node.parent.kind === 195); + } + else { + var exportChanged = node.operatorToken.kind >= 56 && + node.operatorToken.kind <= 68 && + isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.left); + write("\", "); + } + if (node.operatorToken.kind === 38 || node.operatorToken.kind === 60) { + emitExponentiationOperator(node); + } + else { + emit(node.left); + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); + write(ts.tokenToString(node.operatorToken.kind)); + var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); + emit(node.right); + decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + } + if (exportChanged) { + write(")"); + } + } + } + function synthesizedNodeStartsOnNewLine(node) { + return ts.nodeIsSynthesized(node) && node.startsOnNewLine; + } + function emitConditionalExpression(node) { + emit(node.condition); + var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); + write("?"); + var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); + emit(node.whenTrue); + decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); + var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); + write(":"); + var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); + emit(node.whenFalse); + decreaseIndentIf(indentedBeforeColon, indentedAfterColon); + } + function decreaseIndentIf(value1, value2) { + if (value1) { + decreaseIndent(); + } + if (value2) { + decreaseIndent(); + } + } + function isSingleLineEmptyBlock(node) { + if (node && node.kind === 192) { + var block = node; + return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); + } + } + function emitBlock(node) { + if (isSingleLineEmptyBlock(node)) { + emitToken(15, node.pos); + write(" "); + emitToken(16, node.statements.end); + return; + } + emitToken(15, node.pos); + increaseIndent(); + scopeEmitStart(node.parent); + if (node.kind === 219) { + ts.Debug.assert(node.parent.kind === 218); + emitCaptureThisForNodeIfNecessary(node.parent); + } + emitLines(node.statements); + if (node.kind === 219) { + emitTempDeclarations(true); + } + decreaseIndent(); + writeLine(); + emitToken(16, node.statements.end); + scopeEmitEnd(); + } + function emitEmbeddedStatement(node) { + if (node.kind === 192) { + write(" "); + emit(node); + } + else { + increaseIndent(); + writeLine(); + emit(node); + decreaseIndent(); + } + } + function emitExpressionStatement(node) { + emitParenthesizedIf(node.expression, node.expression.kind === 174); + write(";"); + } + function emitIfStatement(node) { + var endPos = emitToken(88, node.pos); + write(" "); + endPos = emitToken(17, endPos); + emit(node.expression); + emitToken(18, node.expression.end); + emitEmbeddedStatement(node.thenStatement); + if (node.elseStatement) { + writeLine(); + emitToken(80, node.thenStatement.end); + if (node.elseStatement.kind === 196) { + write(" "); + emit(node.elseStatement); + } + else { + emitEmbeddedStatement(node.elseStatement); + } + } + } + function emitDoStatement(node) { + write("do"); + emitEmbeddedStatement(node.statement); + if (node.statement.kind === 192) { + write(" "); + } + else { + writeLine(); + } + write("while ("); + emit(node.expression); + write(");"); + } + function emitWhileStatement(node) { + write("while ("); + emit(node.expression); + write(")"); + emitEmbeddedStatement(node.statement); + } + function tryEmitStartOfVariableDeclarationList(decl, startPos) { + if (shouldHoistVariable(decl, true)) { + return false; + } + var tokenKind = 102; + if (decl && languageVersion >= 2) { + if (ts.isLet(decl)) { + tokenKind = 108; + } + else if (ts.isConst(decl)) { + tokenKind = 74; + } + } + if (startPos !== undefined) { + emitToken(tokenKind, startPos); + write(" "); + } + else { + switch (tokenKind) { + case 102: + write("var "); + break; + case 108: + write("let "); + break; + case 74: + write("const "); + break; + } + } + return true; + } + function emitVariableDeclarationListSkippingUninitializedEntries(list) { + var started = false; + for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { + var decl = _b[_a]; + if (!decl.initializer) { + continue; + } + if (!started) { + started = true; + } + else { + write(", "); + } + emit(decl); + } + return started; + } + function emitForStatement(node) { + var endPos = emitToken(86, node.pos); + write(" "); + endPos = emitToken(17, endPos); + if (node.initializer && node.initializer.kind === 212) { + var variableDeclarationList = node.initializer; + var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + if (startIsEmitted) { + emitCommaList(variableDeclarationList.declarations); + } + else { + emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); + } + } + else if (node.initializer) { + emit(node.initializer); + } + write(";"); + emitOptional(" ", node.condition); + write(";"); + emitOptional(" ", node.incrementor); + write(")"); + emitEmbeddedStatement(node.statement); + } + function emitForInOrForOfStatement(node) { + if (languageVersion < 2 && node.kind === 201) { + return emitDownLevelForOfStatement(node); + } + var endPos = emitToken(86, node.pos); + write(" "); + endPos = emitToken(17, endPos); + if (node.initializer.kind === 212) { + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length >= 1) { + tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + emit(variableDeclarationList.declarations[0]); + } + } + else { + emit(node.initializer); + } + if (node.kind === 200) { + write(" in "); + } + else { + write(" of "); + } + emit(node.expression); + emitToken(18, node.expression.end); + emitEmbeddedStatement(node.statement); + } + function emitDownLevelForOfStatement(node) { + var endPos = emitToken(86, node.pos); + write(" "); + endPos = emitToken(17, endPos); + var rhsIsIdentifier = node.expression.kind === 69; + var counter = createTempVariable(268435456); + var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); + emitStart(node.expression); + write("var "); + emitNodeWithoutSourceMap(counter); + write(" = 0"); + emitEnd(node.expression); + if (!rhsIsIdentifier) { + write(", "); + emitStart(node.expression); + emitNodeWithoutSourceMap(rhsReference); + write(" = "); + emitNodeWithoutSourceMap(node.expression); + emitEnd(node.expression); + } + write("; "); + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write(" < "); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); + write(".length"); + emitEnd(node.initializer); + write("; "); + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write("++"); + emitEnd(node.initializer); + emitToken(18, node.expression.end); + write(" {"); + writeLine(); + increaseIndent(); + var rhsIterationValue = createElementAccessExpression(rhsReference, counter); + emitStart(node.initializer); + if (node.initializer.kind === 212) { + write("var "); + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length > 0) { + var declaration = variableDeclarationList.declarations[0]; + if (ts.isBindingPattern(declaration.name)) { + emitDestructuring(declaration, false, rhsIterationValue); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(declaration); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + emitNodeWithoutSourceMap(createTempVariable(0)); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + var assignmentExpression = createBinaryExpression(node.initializer, 56, rhsIterationValue, false); + if (node.initializer.kind === 164 || node.initializer.kind === 165) { + emitDestructuring(assignmentExpression, true, undefined); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); + } + } + emitEnd(node.initializer); + write(";"); + if (node.statement.kind === 192) { + emitLines(node.statement.statements); + } + else { + writeLine(); + emit(node.statement); + } + writeLine(); + decreaseIndent(); + write("}"); + } + function emitBreakOrContinueStatement(node) { + emitToken(node.kind === 203 ? 70 : 75, node.pos); + emitOptional(" ", node.label); + write(";"); + } + function emitReturnStatement(node) { + emitToken(94, node.pos); + emitOptional(" ", node.expression); + write(";"); + } + function emitWithStatement(node) { + write("with ("); + emit(node.expression); + write(")"); + emitEmbeddedStatement(node.statement); + } + function emitSwitchStatement(node) { + var endPos = emitToken(96, node.pos); + write(" "); + emitToken(17, endPos); + emit(node.expression); + endPos = emitToken(18, node.expression.end); + write(" "); + emitCaseBlock(node.caseBlock, endPos); + } + function emitCaseBlock(node, startPos) { + emitToken(15, startPos); + increaseIndent(); + emitLines(node.clauses); + decreaseIndent(); + writeLine(); + emitToken(16, node.clauses.end); + } + function nodeStartPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function nodeEndPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, node2.end); + } + function nodeEndIsOnSameLineAsNodeStart(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function emitCaseOrDefaultClause(node) { + if (node.kind === 241) { + write("case "); + emit(node.expression); + write(":"); + } + else { + write("default:"); + } + if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { + write(" "); + emit(node.statements[0]); + } + else { + increaseIndent(); + emitLines(node.statements); + decreaseIndent(); + } + } + function emitThrowStatement(node) { + write("throw "); + emit(node.expression); + write(";"); + } + function emitTryStatement(node) { + write("try "); + emit(node.tryBlock); + emit(node.catchClause); + if (node.finallyBlock) { + writeLine(); + write("finally "); + emit(node.finallyBlock); + } + } + function emitCatchClause(node) { + writeLine(); + var endPos = emitToken(72, node.pos); + write(" "); + emitToken(17, endPos); + emit(node.variableDeclaration); + emitToken(18, node.variableDeclaration ? node.variableDeclaration.end : endPos); + write(" "); + emitBlock(node.block); + } + function emitDebuggerStatement(node) { + emitToken(76, node.pos); + write(";"); + } + function emitLabelledStatement(node) { + emit(node.label); + write(": "); + emit(node.statement); + } + function getContainingModule(node) { + do { + node = node.parent; + } while (node && node.kind !== 218); + return node; + } + function emitContainingModuleName(node) { + var container = getContainingModule(node); + write(container ? getGeneratedNameForNode(container) : "exports"); + } + function emitModuleMemberName(node) { + emitStart(node.name); + if (ts.getCombinedNodeFlags(node) & 1) { + var container = getContainingModule(node); + if (container) { + write(getGeneratedNameForNode(container)); + write("."); + } + else if (modulekind !== 5 && modulekind !== 4) { + write("exports."); + } + } + emitNodeWithCommentsAndWithoutSourcemap(node.name); + emitEnd(node.name); + } + function createVoidZero() { + var zero = ts.createSynthesizedNode(8); + zero.text = "0"; + var result = ts.createSynthesizedNode(177); + result.expression = zero; + return result; + } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 248) { + ts.Debug.assert(!!(node.flags & 1024) || node.kind === 227); + if (modulekind === 1 || modulekind === 2 || modulekind === 3) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1) { + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } + function emitExportMemberAssignment(node) { + if (node.flags & 1) { + writeLine(); + emitStart(node); + if (modulekind === 4 && node.parent === currentSourceFile) { + write(exportFunctionForFile + "(\""); + if (node.flags & 1024) { + write("default"); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(node.name); + } + write("\", "); + emitDeclarationName(node); + write(")"); + } + else { + if (node.flags & 1024) { + emitEs6ExportDefaultCompat(node); + if (languageVersion === 0) { + write("exports[\"default\"]"); + } + else { + write("exports.default"); + } + } + else { + emitModuleMemberName(node); + } + write(" = "); + emitDeclarationName(node); + } + emitEnd(node); + write(";"); + } + } + function emitExportMemberAssignments(name) { + if (modulekind === 4) { + return; + } + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { + var specifier = _b[_a]; + writeLine(); + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); + write(";"); + } + } + } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(modulekind === 4); + if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { + return; + } + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.name); + write(";"); + } + function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { + if (shouldEmitCommaBeforeAssignment) { + write(", "); + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(name); + write("\", "); + } + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 211 || name.parent.kind === 163); + if (isVariableDeclarationOrBindingElement) { + emitModuleMemberName(name.parent); + } + else { + emit(name); + } + write(" = "); + emit(value); + if (exportChanged) { + write(")"); + } + } + function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { + var identifier = createTempVariable(0); + if (!canDefineTempVariablesInPlace) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); + return identifier; + } + function emitDestructuring(root, isAssignmentExpressionStatement, value) { + var emitCount = 0; + var canDefineTempVariablesInPlace = false; + if (root.kind === 211) { + var isExported = ts.getCombinedNodeFlags(root) & 1; + var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); + canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; + } + else if (root.kind === 138) { + canDefineTempVariablesInPlace = true; + } + if (root.kind === 181) { + emitAssignmentExpression(root); + } + else { + ts.Debug.assert(!isAssignmentExpressionStatement); + emitBindingElement(root, value); + } + function ensureIdentifier(expr, reuseIdentifierExpressions) { + if (expr.kind === 69 && reuseIdentifierExpressions) { + return expr; + } + var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); + emitCount++; + return identifier; + } + function createDefaultValueCheck(value, defaultValue) { + value = ensureIdentifier(value, true); + var equals = ts.createSynthesizedNode(181); + equals.left = value; + equals.operatorToken = ts.createSynthesizedNode(32); + equals.right = createVoidZero(); + return createConditionalExpression(equals, defaultValue, value); + } + function createConditionalExpression(condition, whenTrue, whenFalse) { + var cond = ts.createSynthesizedNode(182); + cond.condition = condition; + cond.questionToken = ts.createSynthesizedNode(53); + cond.whenTrue = whenTrue; + cond.colonToken = ts.createSynthesizedNode(54); + cond.whenFalse = whenFalse; + return cond; + } + function createNumericLiteral(value) { + var node = ts.createSynthesizedNode(8); + node.text = "" + value; + return node; + } + function createPropertyAccessForDestructuringProperty(object, propName) { + var syntheticName = ts.createSynthesizedNode(propName.kind); + syntheticName.text = propName.text; + if (syntheticName.kind !== 69) { + return createElementAccessExpression(object, syntheticName); + } + return createPropertyAccessExpression(object, syntheticName); + } + function createSliceCall(value, sliceIndex) { + var call = ts.createSynthesizedNode(168); + var sliceIdentifier = ts.createSynthesizedNode(69); + sliceIdentifier.text = "slice"; + call.expression = createPropertyAccessExpression(value, sliceIdentifier); + call.arguments = ts.createSynthesizedNodeArray(); + call.arguments[0] = createNumericLiteral(sliceIndex); + return call; + } + function emitObjectLiteralAssignment(target, value) { + var properties = target.properties; + if (properties.length !== 1) { + value = ensureIdentifier(value, true); + } + for (var _a = 0; _a < properties.length; _a++) { + var p = properties[_a]; + if (p.kind === 245 || p.kind === 246) { + var propName = p.name; + var target_1 = p.kind === 246 ? p : p.initializer || propName; + emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); + } + } + } + function emitArrayLiteralAssignment(target, value) { + var elements = target.elements; + if (elements.length !== 1) { + value = ensureIdentifier(value, true); + } + for (var i = 0; i < elements.length; i++) { + var e = elements[i]; + if (e.kind !== 187) { + if (e.kind !== 185) { + emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === elements.length - 1) { + emitDestructuringAssignment(e.expression, createSliceCall(value, i)); + } + } + } + } + function emitDestructuringAssignment(target, value) { + if (target.kind === 246) { + if (target.objectAssignmentInitializer) { + value = createDefaultValueCheck(value, target.objectAssignmentInitializer); + } + target = target.name; + } + else if (target.kind === 181 && target.operatorToken.kind === 56) { + value = createDefaultValueCheck(value, target.right); + target = target.left; + } + if (target.kind === 165) { + emitObjectLiteralAssignment(target, value); + } + else if (target.kind === 164) { + emitArrayLiteralAssignment(target, value); + } + else { + emitAssignment(target, value, emitCount > 0); + emitCount++; + } + } + function emitAssignmentExpression(root) { + var target = root.left; + var value = root.right; + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { + emitDestructuringAssignment(target, value); + } + else { + if (root.parent.kind !== 172) { + write("("); + } + value = ensureIdentifier(value, true); + emitDestructuringAssignment(target, value); + write(", "); + emit(value); + if (root.parent.kind !== 172) { + write(")"); + } + } + } + function emitBindingElement(target, value) { + if (target.initializer) { + value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; + } + else if (!value) { + value = createVoidZero(); + } + if (ts.isBindingPattern(target.name)) { + var pattern = target.name; + var elements = pattern.elements; + var numElements = elements.length; + if (numElements !== 1) { + value = ensureIdentifier(value, numElements !== 0); + } + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (pattern.kind === 161) { + var propName = element.propertyName || element.name; + emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); + } + else if (element.kind !== 187) { + if (!element.dotDotDotToken) { + emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === numElements - 1) { + emitBindingElement(element, createSliceCall(value, i)); + } + } + } + } + else { + emitAssignment(target.name, value, emitCount > 0); + emitCount++; + } + } + } + function emitVariableDeclaration(node) { + if (ts.isBindingPattern(node.name)) { + if (languageVersion < 2) { + emitDestructuring(node, false); + } + else { + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + else { + var initializer = node.initializer; + if (!initializer && languageVersion < 2) { + var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384) && + (getCombinedFlagsForIdentifier(node.name) & 16384); + if (isUninitializedLet && + node.parent.parent.kind !== 200 && + node.parent.parent.kind !== 201) { + initializer = createVoidZero(); + } + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(node.name); + write("\", "); + } + emitModuleMemberName(node); + emitOptional(" = ", initializer); + if (exportChanged) { + write(")"); + } + } + } + function emitExportVariableAssignments(node) { + if (node.kind === 187) { + return; + } + var name = node.name; + if (name.kind === 69) { + emitExportMemberAssignments(name); + } + else if (ts.isBindingPattern(name)) { + ts.forEach(name.elements, emitExportVariableAssignments); + } + } + function getCombinedFlagsForIdentifier(node) { + if (!node.parent || (node.parent.kind !== 211 && node.parent.kind !== 163)) { + return 0; + } + return ts.getCombinedNodeFlags(node.parent); + } + function isES6ExportedDeclaration(node) { + return !!(node.flags & 1) && + modulekind === 5 && + node.parent.kind === 248; + } + function emitVariableStatement(node) { + var startIsEmitted = false; + if (node.flags & 1) { + if (isES6ExportedDeclaration(node)) { + write("export "); + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + } + else { + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + if (startIsEmitted) { + emitCommaList(node.declarationList.declarations); + write(";"); + } + else { + var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); + if (atLeastOneItem) { + write(";"); + } + } + if (modulekind !== 5 && node.parent === currentSourceFile) { + ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); + } + } + function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { + if (!(node.flags & 1)) { + return true; + } + if (isES6ExportedDeclaration(node)) { + return true; + } + for (var _a = 0, _b = node.declarationList.declarations; _a < _b.length; _a++) { + var declaration = _b[_a]; + if (declaration.initializer) { + return true; + } + } + return false; + } + function emitParameter(node) { + if (languageVersion < 2) { + if (ts.isBindingPattern(node.name)) { + var name_24 = createTempVariable(0); + if (!tempParameters) { + tempParameters = []; + } + tempParameters.push(name_24); + emit(name_24); + } + else { + emit(node.name); + } + } + else { + if (node.dotDotDotToken) { + write("..."); + } + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + function emitDefaultValueAssignments(node) { + if (languageVersion < 2) { + var tempIndex = 0; + ts.forEach(node.parameters, function (parameter) { + if (parameter.dotDotDotToken) { + return; + } + var paramName = parameter.name, initializer = parameter.initializer; + if (ts.isBindingPattern(paramName)) { + var hasBindingElements = paramName.elements.length > 0; + if (hasBindingElements || initializer) { + writeLine(); + write("var "); + if (hasBindingElements) { + emitDestructuring(parameter, false, tempParameters[tempIndex]); + } + else { + emit(tempParameters[tempIndex]); + write(" = "); + emit(initializer); + } + write(";"); + tempIndex++; + } + } + else if (initializer) { + writeLine(); + emitStart(parameter); + write("if ("); + emitNodeWithoutSourceMap(paramName); + write(" === void 0)"); + emitEnd(parameter); + write(" { "); + emitStart(parameter); + emitNodeWithCommentsAndWithoutSourcemap(paramName); + write(" = "); + emitNodeWithCommentsAndWithoutSourcemap(initializer); + emitEnd(parameter); + write("; }"); + } + }); + } + } + function emitRestParameter(node) { + if (languageVersion < 2 && ts.hasRestParameter(node)) { + var restIndex = node.parameters.length - 1; + var restParam = node.parameters[restIndex]; + if (ts.isBindingPattern(restParam.name)) { + return; + } + var tempName = createTempVariable(268435456).text; + writeLine(); + emitLeadingComments(restParam); + emitStart(restParam); + write("var "); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + write(" = [];"); + emitEnd(restParam); + emitTrailingComments(restParam); + writeLine(); + write("for ("); + emitStart(restParam); + write("var " + tempName + " = " + restIndex + ";"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + " < arguments.length;"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + "++"); + emitEnd(restParam); + write(") {"); + increaseIndent(); + writeLine(); + emitStart(restParam); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); + emitEnd(restParam); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitAccessor(node) { + write(node.kind === 145 ? "get " : "set "); + emit(node.name); + emitSignatureAndBody(node); + } + function shouldEmitAsArrowFunction(node) { + return node.kind === 174 && languageVersion >= 2; + } + function emitDeclarationName(node) { + if (node.name) { + emitNodeWithCommentsAndWithoutSourcemap(node.name); + } + else { + write(getGeneratedNameForNode(node)); + } + } + function shouldEmitFunctionName(node) { + if (node.kind === 173) { + return !!node.name; + } + if (node.kind === 213) { + return !!node.name || languageVersion < 2; + } + } + function emitFunctionDeclaration(node) { + if (ts.nodeIsMissing(node.body)) { + return emitCommentsOnNotEmittedNode(node); + } + if (node.kind !== 143 && node.kind !== 142 && + node.parent && node.parent.kind !== 245 && + node.parent.kind !== 168) { + emitLeadingComments(node); + } + emitStart(node); + if (!shouldEmitAsArrowFunction(node)) { + if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 1024) { + write("default "); + } + } + write("function"); + if (languageVersion >= 2 && node.asteriskToken) { + write("*"); + } + write(" "); + } + if (shouldEmitFunctionName(node)) { + emitDeclarationName(node); + } + emitSignatureAndBody(node); + if (modulekind !== 5 && node.kind === 213 && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + emitEnd(node); + if (node.kind !== 143 && node.kind !== 142) { + emitTrailingComments(node); + } + } + function emitCaptureThisForNodeIfNecessary(node) { + if (resolver.getNodeCheckFlags(node) & 4) { + writeLine(); + emitStart(node); + write("var _this = this;"); + emitEnd(node); + } + } + function emitSignatureParameters(node) { + increaseIndent(); + write("("); + if (node) { + var parameters = node.parameters; + var omitCount = languageVersion < 2 && ts.hasRestParameter(node) ? 1 : 0; + emitList(parameters, 0, parameters.length - omitCount, false, false); + } + write(")"); + decreaseIndent(); + } + function emitSignatureParametersForArrow(node) { + if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { + emit(node.parameters[0]); + return; + } + emitSignatureParameters(node); + } + function emitAsyncFunctionBodyForES6(node) { + var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); + var isArrowFunction = node.kind === 174; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; + var args; + if (!isArrowFunction) { + write(" {"); + increaseIndent(); + writeLine(); + write("return"); + } + write(" __awaiter(this"); + if (hasLexicalArguments) { + write(", arguments"); + } + else { + write(", void 0"); + } + if (promiseConstructor) { + write(", "); + emitNodeWithoutSourceMap(promiseConstructor); + } + else { + write(", Promise"); + } + if (hasLexicalArguments) { + write(", function* (_arguments)"); + } + else { + write(", function* ()"); + } + emitFunctionBody(node); + write(")"); + if (!isArrowFunction) { + write(";"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitFunctionBody(node) { + if (!node.body) { + write(" { }"); + } + else { + if (node.body.kind === 192) { + emitBlockFunctionBody(node, node.body); + } + else { + emitExpressionFunctionBody(node, node.body); + } + } + } + function emitSignatureAndBody(node) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + if (shouldEmitAsArrowFunction(node)) { + emitSignatureParametersForArrow(node); + write(" =>"); + } + else { + emitSignatureParameters(node); + } + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync && languageVersion === 2) { + emitAsyncFunctionBodyForES6(node); + } + else { + emitFunctionBody(node); + } + if (!isES6ExportedDeclaration(node)) { + emitExportMemberAssignment(node); + } + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + function emitFunctionBodyPreamble(node) { + emitCaptureThisForNodeIfNecessary(node); + emitDefaultValueAssignments(node); + emitRestParameter(node); + } + function emitExpressionFunctionBody(node, body) { + if (languageVersion < 2 || node.flags & 512) { + emitDownLevelExpressionFunctionBody(node, body); + return; + } + write(" "); + var current = body; + while (current.kind === 171) { + current = current.expression; + } + emitParenthesizedIf(body, current.kind === 165); + } + function emitDownLevelExpressionFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + increaseIndent(); + var outPos = writer.getTextPos(); + emitDetachedComments(node.body); + emitFunctionBodyPreamble(node); + var preambleEmitted = writer.getTextPos() !== outPos; + decreaseIndent(); + if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { + write(" "); + emitStart(body); + write("return "); + emit(body); + emitEnd(body); + write(";"); + emitTempDeclarations(false); + write(" "); + } + else { + increaseIndent(); + writeLine(); + emitLeadingComments(node.body); + write("return "); + emit(body); + write(";"); + emitTrailingComments(node.body); + emitTempDeclarations(true); + decreaseIndent(); + writeLine(); + } + emitStart(node.body); + write("}"); + emitEnd(node.body); + scopeEmitEnd(); + } + function emitBlockFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + var initialTextPos = writer.getTextPos(); + increaseIndent(); + emitDetachedComments(body.statements); + var startIndex = emitDirectivePrologues(body.statements, true); + emitFunctionBodyPreamble(node); + decreaseIndent(); + var preambleEmitted = writer.getTextPos() !== initialTextPos; + if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { + for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { + var statement = _b[_a]; + write(" "); + emit(statement); + } + emitTempDeclarations(false); + write(" "); + emitLeadingCommentsOfPosition(body.statements.end); + } + else { + increaseIndent(); + emitLinesStartingAt(body.statements, startIndex); + emitTempDeclarations(true); + writeLine(); + emitLeadingCommentsOfPosition(body.statements.end); + decreaseIndent(); + } + emitToken(16, body.statements.end); + scopeEmitEnd(); + } + function findInitialSuperCall(ctor) { + if (ctor.body) { + var statement = ctor.body.statements[0]; + if (statement && statement.kind === 195) { + var expr = statement.expression; + if (expr && expr.kind === 168) { + var func = expr.expression; + if (func && func.kind === 95) { + return statement; + } + } + } + } + } + function emitParameterPropertyAssignments(node) { + ts.forEach(node.parameters, function (param) { + if (param.flags & 112) { + writeLine(); + emitStart(param); + emitStart(param.name); + write("this."); + emitNodeWithoutSourceMap(param.name); + emitEnd(param.name); + write(" = "); + emit(param.name); + write(";"); + emitEnd(param); + } + }); + } + function emitMemberAccessForPropertyName(memberName) { + if (memberName.kind === 9 || memberName.kind === 8) { + write("["); + emitNodeWithCommentsAndWithoutSourcemap(memberName); + write("]"); + } + else if (memberName.kind === 136) { + emitComputedPropertyName(memberName); + } + else { + write("."); + emitNodeWithCommentsAndWithoutSourcemap(memberName); + } + } + function getInitializedProperties(node, isStatic) { + var properties = []; + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if (member.kind === 141 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + properties.push(member); + } + } + return properties; + } + function emitPropertyDeclarations(node, properties) { + for (var _a = 0; _a < properties.length; _a++) { + var property = properties[_a]; + emitPropertyDeclaration(node, property); + } + } + function emitPropertyDeclaration(node, property, receiver, isExpression) { + writeLine(); + emitLeadingComments(property); + emitStart(property); + emitStart(property.name); + if (receiver) { + emit(receiver); + } + else { + if (property.flags & 128) { + emitDeclarationName(node); + } + else { + write("this"); + } + } + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + emit(property.initializer); + if (!isExpression) { + write(";"); + } + emitEnd(property); + emitTrailingComments(property); + } + function emitMemberFunctionsForES5AndLower(node) { + ts.forEach(node.members, function (member) { + if (member.kind === 191) { + writeLine(); + write(";"); + } + else if (member.kind === 143 || node.kind === 142) { + if (!member.body) { + return emitCommentsOnNotEmittedNode(member); + } + writeLine(); + emitLeadingComments(member); + emitStart(member); + emitStart(member.name); + emitClassMemberPrefix(node, member); + emitMemberAccessForPropertyName(member.name); + emitEnd(member.name); + write(" = "); + emitFunctionDeclaration(member); + emitEnd(member); + write(";"); + emitTrailingComments(member); + } + else if (member.kind === 145 || member.kind === 146) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member === accessors.firstAccessor) { + writeLine(); + emitStart(member); + write("Object.defineProperty("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("});"); + emitEnd(member); + } + } + }); + } + function emitMemberFunctionsForES6AndHigher(node) { + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if ((member.kind === 143 || node.kind === 142) && !member.body) { + emitCommentsOnNotEmittedNode(member); + } + else if (member.kind === 143 || + member.kind === 145 || + member.kind === 146) { + writeLine(); + emitLeadingComments(member); + emitStart(member); + if (member.flags & 128) { + write("static "); + } + if (member.kind === 145) { + write("get "); + } + else if (member.kind === 146) { + write("set "); + } + if (member.asteriskToken) { + write("*"); + } + emit(member.name); + emitSignatureAndBody(member); + emitEnd(member); + emitTrailingComments(member); + } + else if (member.kind === 191) { + writeLine(); + write(";"); + } + } + } + function emitConstructor(node, baseTypeElement) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + emitConstructorWorker(node, baseTypeElement); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + function emitConstructorWorker(node, baseTypeElement) { + var hasInstancePropertyWithInitializer = false; + ts.forEach(node.members, function (member) { + if (member.kind === 144 && !member.body) { + emitCommentsOnNotEmittedNode(member); + } + if (member.kind === 141 && 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 (baseTypeElement) { + write("(...args)"); + } + else { + write("()"); + } + } + } + var startIndex = 0; + write(" {"); + scopeEmitStart(node, "constructor"); + increaseIndent(); + if (ctor) { + startIndex = emitDirectivePrologues(ctor.body.statements, true); + emitDetachedComments(ctor.body.statements); + } + emitCaptureThisForNodeIfNecessary(node); + var superCall; + if (ctor) { + emitDefaultValueAssignments(ctor); + emitRestParameter(ctor); + if (baseTypeElement) { + superCall = findInitialSuperCall(ctor); + if (superCall) { + writeLine(); + emit(superCall); + } + } + emitParameterPropertyAssignments(ctor); + } + else { + if (baseTypeElement) { + writeLine(); + emitStart(baseTypeElement); + if (languageVersion < 2) { + write("_super.apply(this, arguments);"); + } + else { + write("super(...args);"); + } + emitEnd(baseTypeElement); + } + } + emitPropertyDeclarations(node, getInitializedProperties(node, false)); + if (ctor) { + var statements = ctor.body.statements; + if (superCall) { + statements = statements.slice(1); + } + emitLinesStartingAt(statements, startIndex); + } + emitTempDeclarations(true); + writeLine(); + if (ctor) { + emitLeadingCommentsOfPosition(ctor.body.statements.end); + } + decreaseIndent(); + emitToken(16, ctor ? ctor.body.statements.end : node.members.end); + scopeEmitEnd(); + emitEnd(ctor || node); + if (ctor) { + emitTrailingComments(ctor); + } + } + function emitClassExpression(node) { + return emitClassLikeDeclaration(node); + } + function emitClassDeclaration(node) { + return emitClassLikeDeclaration(node); + } + function emitClassLikeDeclaration(node) { + if (languageVersion < 2) { + emitClassLikeDeclarationBelowES6(node); + } + else { + emitClassLikeDeclarationForES6AndHigher(node); + } + if (modulekind !== 5 && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + } + function emitClassLikeDeclarationForES6AndHigher(node) { + var thisNodeIsDecorated = ts.nodeIsDecorated(node); + if (node.kind === 214) { + if (thisNodeIsDecorated) { + if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { + write("export "); + } + write("let "); + emitDeclarationName(node); + write(" = "); + } + else if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 1024) { + write("default "); + } + } + } + var staticProperties = getInitializedProperties(node, true); + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 186; + var tempVariable; + if (isClassExpressionWithStaticProperties) { + tempVariable = createAndRecordTempVariable(0); + write("("); + increaseIndent(); + emit(tempVariable); + write(" = "); + } + write("class"); + if ((node.name || (node.flags & 1024 && staticProperties.length > 0)) && !thisNodeIsDecorated) { + write(" "); + emitDeclarationName(node); + } + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + write(" extends "); + emit(baseTypeNode.expression); + } + write(" {"); + increaseIndent(); + scopeEmitStart(node); + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES6AndHigher(node); + decreaseIndent(); + writeLine(); + emitToken(16, node.members.end); + scopeEmitEnd(); + if (thisNodeIsDecorated) { + write(";"); + } + if (isClassExpressionWithStaticProperties) { + for (var _a = 0; _a < staticProperties.length; _a++) { + var property = staticProperties[_a]; + write(","); + writeLine(); + emitPropertyDeclaration(node, property, tempVariable, true); + } + write(","); + writeLine(); + emit(tempVariable); + decreaseIndent(); + write(")"); + } + else { + writeLine(); + emitPropertyDeclarations(node, staticProperties); + 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 & 1024) && thisNodeIsDecorated) { + writeLine(); + write("export default "); + emitDeclarationName(node); + write(";"); + } + } + function emitClassLikeDeclarationBelowES6(node) { + if (node.kind === 214) { + if (!shouldHoistDeclarationInSystemJsModule(node)) { + write("var "); + } + emitDeclarationName(node); + write(" = "); + } + write("(function ("); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + 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) { + writeLine(); + emitStart(baseTypeNode); + write("__extends("); + emitDeclarationName(node); + write(", _super);"); + emitEnd(baseTypeNode); + } + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES5AndLower(node); + emitPropertyDeclarations(node, getInitializedProperties(node, true)); + writeLine(); + emitDecoratorsOfClass(node); + writeLine(); + emitToken(16, node.members.end, function () { + write("return "); + emitDeclarationName(node); + }); + write(";"); + emitTempDeclarations(true); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; + decreaseIndent(); + writeLine(); + emitToken(16, node.members.end); + scopeEmitEnd(); + emitStart(node); + write(")("); + if (baseTypeNode) { + emit(baseTypeNode.expression); + } + write(")"); + if (node.kind === 214) { + write(";"); + } + emitEnd(node); + if (node.kind === 214) { + emitExportMemberAssignment(node); + } + } + 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 decorators = node.decorators; + var constructor = ts.getFirstConstructorWithBody(node); + var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); + if (!decorators && !hasDecoratedParameters) { + return; + } + writeLine(); + emitStart(node); + emitDeclarationName(node); + write(" = __decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(constructor, argumentsWritten > 0); + emitSerializedTypeMetadata(node, argumentsWritten >= 0); + decreaseIndent(); + writeLine(); + write("], "); + emitDeclarationName(node); + write(");"); + emitEnd(node); + writeLine(); + } + function emitDecoratorsOfMembers(node, staticFlag) { + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if ((member.flags & 128) !== staticFlag) { + continue; + } + if (!ts.nodeCanBeDecorated(member)) { + continue; + } + if (!ts.nodeOrChildIsDecorated(member)) { + continue; + } + var decorators = void 0; + var functionLikeMember = void 0; + if (ts.isAccessor(member)) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member !== accessors.firstAccessor) { + continue; + } + decorators = accessors.firstAccessor.decorators; + if (!decorators && accessors.secondAccessor) { + decorators = accessors.secondAccessor.decorators; + } + functionLikeMember = accessors.setAccessor; + } + else { + decorators = member.decorators; + if (member.kind === 143) { + functionLikeMember = member; + } + } + writeLine(); + emitStart(member); + write("__decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); + emitSerializedTypeMetadata(member, argumentsWritten > 0); + decreaseIndent(); + writeLine(); + write("], "); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + if (languageVersion > 0) { + if (member.kind !== 141) { + write(", null"); + } + else { + write(", void 0"); + } + } + write(");"); + emitEnd(member); + writeLine(); + } + } + function emitDecoratorsOfParameters(node, leadingComma) { + var argumentsWritten = 0; + if (node) { + var parameterIndex = 0; + for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { + var parameter = _b[_a]; + if (ts.nodeIsDecorated(parameter)) { + var decorators = parameter.decorators; + argumentsWritten += emitList(decorators, 0, decorators.length, true, false, leadingComma, true, function (decorator) { + emitStart(decorator); + write("__param(" + parameterIndex + ", "); + emit(decorator.expression); + write(")"); + emitEnd(decorator); + }); + leadingComma = true; + } + ++parameterIndex; + } + } + return argumentsWritten; + } + function shouldEmitTypeMetadata(node) { + switch (node.kind) { + case 143: + case 145: + case 146: + case 141: + return true; + } + return false; + } + function shouldEmitReturnTypeMetadata(node) { + switch (node.kind) { + case 143: + return true; + } + return false; + } + function shouldEmitParamTypesMetadata(node) { + switch (node.kind) { + case 214: + case 143: + case 146: + return true; + } + return false; + } + function emitSerializedTypeOfNode(node) { + switch (node.kind) { + case 214: + write("Function"); + return; + case 141: + emitSerializedTypeNode(node.type); + return; + case 138: + emitSerializedTypeNode(node.type); + return; + case 145: + emitSerializedTypeNode(node.type); + return; + case 146: + emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); + return; + } + if (ts.isFunctionLike(node)) { + write("Function"); + return; + } + write("void 0"); + } + function emitSerializedTypeNode(node) { + if (node) { + switch (node.kind) { + case 103: + write("void 0"); + return; + case 160: + emitSerializedTypeNode(node.type); + return; + case 152: + case 153: + write("Function"); + return; + case 156: + case 157: + write("Array"); + return; + case 150: + case 120: + write("Boolean"); + return; + case 130: + case 9: + write("String"); + return; + case 128: + write("Number"); + return; + case 131: + write("Symbol"); + return; + case 151: + emitSerializedTypeReferenceNode(node); + return; + case 154: + case 155: + case 158: + case 159: + case 117: + break; + default: + ts.Debug.fail("Cannot serialize unexpected type node."); + break; + } + } + write("Object"); + } + function emitSerializedTypeReferenceNode(node) { + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); + switch (result) { + case ts.TypeReferenceSerializationKind.Unknown: + var temp = createAndRecordTempVariable(0); + write("(typeof ("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(typeName, true); + write(") === 'function' && "); + emitNodeWithoutSourceMap(temp); + write(") || Object"); + break; + case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: + emitEntityNameAsExpression(typeName, false); + break; + case ts.TypeReferenceSerializationKind.VoidType: + write("void 0"); + break; + case ts.TypeReferenceSerializationKind.BooleanType: + write("Boolean"); + break; + case ts.TypeReferenceSerializationKind.NumberLikeType: + write("Number"); + break; + case ts.TypeReferenceSerializationKind.StringLikeType: + write("String"); + break; + case ts.TypeReferenceSerializationKind.ArrayLikeType: + write("Array"); + break; + case ts.TypeReferenceSerializationKind.ESSymbolType: + if (languageVersion < 2) { + write("typeof Symbol === 'function' ? Symbol : Object"); + } + else { + write("Symbol"); + } + break; + case ts.TypeReferenceSerializationKind.TypeWithCallSignature: + write("Function"); + break; + case ts.TypeReferenceSerializationKind.ObjectType: + write("Object"); + break; + } + } + function emitSerializedParameterTypesOfNode(node) { + if (node) { + var valueDeclaration; + if (node.kind === 214) { + valueDeclaration = ts.getFirstConstructorWithBody(node); + } + else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { + valueDeclaration = node; + } + if (valueDeclaration) { + var parameters = valueDeclaration.parameters; + var parameterCount = parameters.length; + if (parameterCount > 0) { + for (var i = 0; i < parameterCount; i++) { + if (i > 0) { + write(", "); + } + if (parameters[i].dotDotDotToken) { + var parameterType = parameters[i].type; + if (parameterType.kind === 156) { + parameterType = parameterType.elementType; + } + else if (parameterType.kind === 151 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + parameterType = parameterType.typeArguments[0]; + } + else { + parameterType = undefined; + } + emitSerializedTypeNode(parameterType); + } + else { + emitSerializedTypeOfNode(parameters[i]); + } + } + } + } + } + } + function emitSerializedReturnTypeOfNode(node) { + if (node && ts.isFunctionLike(node) && node.type) { + emitSerializedTypeNode(node.type); + return; + } + write("void 0"); + } + function emitSerializedTypeMetadata(node, writeComma) { + var argumentsWritten = 0; + if (compilerOptions.emitDecoratorMetadata) { + if (shouldEmitTypeMetadata(node)) { + if (writeComma) { + write(", "); + } + writeLine(); + write("__metadata('design:type', "); + emitSerializedTypeOfNode(node); + write(")"); + argumentsWritten++; + } + if (shouldEmitParamTypesMetadata(node)) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:paramtypes', ["); + emitSerializedParameterTypesOfNode(node); + write("])"); + argumentsWritten++; + } + if (shouldEmitReturnTypeMetadata(node)) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:returntype', "); + emitSerializedReturnTypeOfNode(node); + write(")"); + argumentsWritten++; + } + } + return argumentsWritten; + } + function emitInterfaceDeclaration(node) { + emitCommentsOnNotEmittedNode(node); + } + function shouldEmitEnumDeclaration(node) { + var isConstEnum = ts.isConst(node); + return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; + } + function emitEnumDeclaration(node) { + if (!shouldEmitEnumDeclaration(node)) { + return; + } + if (!shouldHoistDeclarationInSystemJsModule(node)) { + if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + emitEnd(node); + write(";"); + } + } + writeLine(); + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") {"); + increaseIndent(); + scopeEmitStart(node); + emitLines(node.members); + decreaseIndent(); + writeLine(); + emitToken(16, node.members.end); + scopeEmitEnd(); + write(")("); + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.flags & 1 && !shouldHoistDeclarationInSystemJsModule(node)) { + writeLine(); + emitStart(node); + write("var "); + emit(node.name); + write(" = "); + emitModuleMemberName(node); + emitEnd(node); + write(";"); + } + if (modulekind !== 5 && node.parent === currentSourceFile) { + if (modulekind === 4 && (node.flags & 1)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(");"); + } + emitExportMemberAssignments(node.name); + } + } + function emitEnumMember(node) { + var enumParent = node.parent; + emitStart(node); + write(getGeneratedNameForNode(enumParent)); + write("["); + write(getGeneratedNameForNode(enumParent)); + write("["); + emitExpressionForPropertyName(node.name); + write("] = "); + writeEnumMemberDeclarationValue(node); + write("] = "); + emitExpressionForPropertyName(node.name); + emitEnd(node); + write(";"); + } + function writeEnumMemberDeclarationValue(member) { + var value = resolver.getConstantValue(member); + if (value !== undefined) { + write(value.toString()); + return; + } + else if (member.initializer) { + emit(member.initializer); + } + else { + write("undefined"); + } + } + function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { + if (moduleDeclaration.body.kind === 218) { + var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); + return recursiveInnerModule || moduleDeclaration.body; + } + } + function shouldEmitModuleDeclaration(node) { + return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); + } + function isModuleMergedWithES6Class(node) { + return languageVersion === 2 && !!(resolver.getNodeCheckFlags(node) & 32768); + } + function emitModuleDeclaration(node) { + var shouldEmit = shouldEmitModuleDeclaration(node); + if (!shouldEmit) { + return emitCommentsOnNotEmittedNode(node); + } + var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); + var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); + if (emitVarForModule) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + write(";"); + emitEnd(node); + writeLine(); + } + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") "); + if (node.body.kind === 219) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + tempFlags = 0; + tempVariables = undefined; + emit(node.body); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + } + else { + write("{"); + increaseIndent(); + scopeEmitStart(node); + emitCaptureThisForNodeIfNecessary(node); + writeLine(); + emit(node.body); + decreaseIndent(); + writeLine(); + var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; + emitToken(16, moduleBlock.statements.end); + scopeEmitEnd(); + } + write(")("); + if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { + emit(node.name); + write(" = "); + } + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.name.kind === 69 && node.parent === currentSourceFile) { + if (modulekind === 4 && (node.flags & 1)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(");"); + } + emitExportMemberAssignments(node.name); + } + } + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } + function emitRequire(moduleName) { + if (moduleName.kind === 9) { + write("require("); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18, moduleName.end); + } + else { + write("require()"); + } + } + function getNamespaceDeclarationNode(node) { + if (node.kind === 221) { + return node; + } + var importClause = node.importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 224) { + return importClause.namedBindings; + } + } + function isDefaultImport(node) { + return node.kind === 222 && 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) { + if (modulekind !== 5) { + 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 === 224) { + 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 === 221 && (node.flags & 1) !== 0; + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (modulekind !== 2) { + emitLeadingComments(node); + emitStart(node); + if (namespaceDeclaration && !isDefaultImport(node)) { + if (!isExportedImport) + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + } + else { + var isNakedImport = 222 && !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 (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)) { + emitExternalImportDeclaration(node); + return; + } + if (resolver.isReferencedAliasDeclaration(node) || + (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { + emitLeadingComments(node); + emitStart(node); + var variableDeclarationIsHoisted = shouldHoistVariable(node, true); + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1)) { + write("var "); + } + } + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); + } + emitModuleMemberName(node); + write(" = "); + emit(node.moduleReference); + if (isExported) { + write(")"); + } + write(";"); + emitEnd(node); + emitExportImportAssignments(node); + emitTrailingComments(node); + } + } + function emitExportDeclaration(node) { + ts.Debug.assert(modulekind !== 4); + if (modulekind !== 5) { + if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { + emitStart(node); + var generatedName = getGeneratedNameForNode(node); + if (node.exportClause) { + if (modulekind !== 2) { + write("var "); + write(generatedName); + write(" = "); + emitRequire(ts.getExternalModuleName(node)); + write(";"); + } + for (var _a = 0, _b = node.exportClause.elements; _a < _b.length; _a++) { + var specifier = _b[_a]; + if (resolver.isValueAliasDeclaration(specifier)) { + writeLine(); + emitStart(specifier); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write(" = "); + write(generatedName); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); + write(";"); + emitEnd(specifier); + } + } + } + else { + writeLine(); + write("__export("); + if (modulekind !== 2) { + emitRequire(ts.getExternalModuleName(node)); + } + else { + write(generatedName); + } + write(");"); + } + emitEnd(node); + } + } + else { + if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { + write("export "); + if (node.exportClause) { + write("{ "); + emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + emit(node.moduleSpecifier); + } + write(";"); + } + } + } + function emitExportOrImportSpecifierList(specifiers, shouldEmit) { + ts.Debug.assert(modulekind === 5); + var needsComma = false; + for (var _a = 0; _a < specifiers.length; _a++) { + var specifier = specifiers[_a]; + if (shouldEmit(specifier)) { + if (needsComma) { + write(", "); + } + if (specifier.propertyName) { + emit(specifier.propertyName); + write(" as "); + } + emit(specifier.name); + needsComma = true; + } + } + } + function emitExportAssignment(node) { + if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { + if (modulekind === 5) { + writeLine(); + emitStart(node); + write("export default "); + var expression = node.expression; + emit(expression); + if (expression.kind !== 213 && + expression.kind !== 214) { + write(";"); + } + emitEnd(node); + } + else { + writeLine(); + emitStart(node); + if (modulekind === 4) { + write(exportFunctionForFile + "(\"default\","); + emit(node.expression); + write(")"); + } + else { + emitEs6ExportDefaultCompat(node); + emitContainingModuleName(node); + if (languageVersion === 0) { + write("[\"default\"] = "); + } + else { + write(".default = "); + } + emit(node.expression); + } + write(";"); + emitEnd(node); + } + } + } + function collectExternalModuleInfo(sourceFile) { + externalImports = []; + exportSpecifiers = {}; + exportEquals = undefined; + hasExportStars = false; + for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { + var node = _b[_a]; + switch (node.kind) { + case 222: + if (!node.importClause || + resolver.isReferencedAliasDeclaration(node.importClause, true)) { + externalImports.push(node); + } + break; + case 221: + if (node.moduleReference.kind === 232 && resolver.isReferencedAliasDeclaration(node)) { + externalImports.push(node); + } + break; + case 228: + if (node.moduleSpecifier) { + if (!node.exportClause) { + externalImports.push(node); + hasExportStars = true; + } + else if (resolver.isValueAliasDeclaration(node)) { + externalImports.push(node); + } + } + else { + for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { + var specifier = _d[_c]; + var name_25 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_25] || (exportSpecifiers[name_25] = [])).push(specifier); + } + } + break; + case 227: + if (node.isExportEquals && !exportEquals) { + exportEquals = node; + } + break; + } + } + } + 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 getLocalNameForExternalImport(node) { + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (namespaceDeclaration && !isDefaultImport(node)) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); + } + if (node.kind === 222 && node.importClause) { + return getGeneratedNameForNode(node); + } + if (node.kind === 228 && node.moduleSpecifier) { + return getGeneratedNameForNode(node); + } + } + function getExternalModuleNameText(importNode) { + var moduleName = ts.getExternalModuleName(importNode); + if (moduleName.kind === 9) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); + } + return undefined; + } + function emitVariableDeclarationsForImports() { + if (externalImports.length === 0) { + return; + } + writeLine(); + var started = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var importNode = externalImports[_a]; + var skipNode = importNode.kind === 228 || + (importNode.kind === 222 && !importNode.importClause); + if (skipNode) { + continue; + } + if (!started) { + write("var "); + started = true; + } + else { + write(", "); + } + write(getLocalNameForExternalImport(importNode)); + } + if (started) { + write(";"); + } + } + function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { + if (!hasExportStars) { + return undefined; + } + if (!exportedDeclarations && ts.isEmpty(exportSpecifiers)) { + var hasExportDeclarationWithExportClause = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var externalImport = externalImports[_a]; + if (externalImport.kind === 228 && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + return emitExportStarFunction(undefined); + } + } + var exportedNamesStorageRef = makeUniqueName("exportedNames"); + writeLine(); + write("var " + exportedNamesStorageRef + " = {"); + increaseIndent(); + var started = false; + if (exportedDeclarations) { + for (var i = 0; i < exportedDeclarations.length; ++i) { + writeExportedName(exportedDeclarations[i]); + } + } + if (exportSpecifiers) { + for (var n in exportSpecifiers) { + for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { + var specifier = _c[_b]; + writeExportedName(specifier.name); + } + } + } + for (var _d = 0; _d < externalImports.length; _d++) { + var externalImport = externalImports[_d]; + if (externalImport.kind !== 228) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + continue; + } + for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { + var element = _f[_e]; + writeExportedName(element.name || element.propertyName); + } + } + decreaseIndent(); + writeLine(); + write("};"); + return emitExportStarFunction(exportedNamesStorageRef); + function emitExportStarFunction(localNames) { + var exportStarFunction = makeUniqueName("exportStar"); + writeLine(); + write("function " + exportStarFunction + "(m) {"); + increaseIndent(); + writeLine(); + write("var exports = {};"); + writeLine(); + write("for(var n in m) {"); + increaseIndent(); + writeLine(); + write("if (n !== \"default\""); + if (localNames) { + write("&& !" + localNames + ".hasOwnProperty(n)"); + } + write(") exports[n] = m[n];"); + decreaseIndent(); + writeLine(); + write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); + decreaseIndent(); + writeLine(); + write("}"); + return exportStarFunction; + } + function writeExportedName(node) { + if (node.kind !== 69 && node.flags & 1024) { + return; + } + if (started) { + write(","); + } + else { + started = true; + } + writeLine(); + write("'"); + if (node.kind === 69) { + emitNodeWithCommentsAndWithoutSourcemap(node); + } + else { + emitDeclarationName(node); + } + write("': true"); + } + } + function processTopLevelVariableAndFunctionDeclarations(node) { + var hoistedVars; + var hoistedFunctionDeclarations; + var exportedDeclarations; + visit(node); + if (hoistedVars) { + writeLine(); + write("var "); + var seen = {}; + for (var i = 0; i < hoistedVars.length; ++i) { + var local = hoistedVars[i]; + var name_26 = local.kind === 69 + ? local + : local.name; + if (name_26) { + var text = ts.unescapeIdentifier(name_26.text); + if (ts.hasProperty(seen, text)) { + continue; + } + else { + seen[text] = text; + } + } + if (i !== 0) { + write(", "); + } + if (local.kind === 214 || local.kind === 218 || local.kind === 217) { + emitDeclarationName(local); + } + else { + emit(local); + } + var flags = ts.getCombinedNodeFlags(local.kind === 69 ? local.parent : local); + if (flags & 1) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(local); + } + } + write(";"); + } + if (hoistedFunctionDeclarations) { + for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { + var f = hoistedFunctionDeclarations[_a]; + writeLine(); + emit(f); + if (f.flags & 1) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(f); + } + } + } + return exportedDeclarations; + function visit(node) { + if (node.flags & 2) { + return; + } + if (node.kind === 213) { + if (!hoistedFunctionDeclarations) { + hoistedFunctionDeclarations = []; + } + hoistedFunctionDeclarations.push(node); + return; + } + if (node.kind === 214) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + return; + } + if (node.kind === 217) { + if (shouldEmitEnumDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 218) { + if (shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 211 || node.kind === 163) { + if (shouldHoistVariable(node, false)) { + var name_27 = node.name; + if (name_27.kind === 69) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(name_27); + } + else { + ts.forEachChild(name_27, visit); + } + } + return; + } + if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } + if (ts.isBindingPattern(node)) { + ts.forEach(node.elements, visit); + return; + } + if (!ts.isDeclaration(node)) { + ts.forEachChild(node, visit); + } + } + } + function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { + if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { + return false; + } + return (ts.getCombinedNodeFlags(node) & 49152) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 248; + } + function isCurrentFileSystemExternalModule() { + return modulekind === 4 && ts.isExternalModule(currentSourceFile); + } + function emitSystemModuleBody(node, dependencyGroups, startIndex) { + emitVariableDeclarationsForImports(); + writeLine(); + var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); + var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); + writeLine(); + write("return {"); + increaseIndent(); + writeLine(); + emitSetters(exportStarFunction, dependencyGroups); + writeLine(); + emitExecute(node, startIndex); + decreaseIndent(); + writeLine(); + write("}"); + emitTempDeclarations(true); + } + function emitSetters(exportStarFunction, dependencyGroups) { + write("setters:["); + for (var i = 0; i < dependencyGroups.length; ++i) { + if (i !== 0) { + write(","); + } + writeLine(); + increaseIndent(); + var group = dependencyGroups[i]; + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); + write("function (" + parameterName + ") {"); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 222: + if (!entry.importClause) { + break; + } + case 221: + ts.Debug.assert(importVariableName !== ""); + writeLine(); + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 228: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { + writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); + } + else { + writeLine(); + write(exportStarFunction + "(" + parameterName + ");"); + } + writeLine(); + break; + } + } + decreaseIndent(); + write("}"); + decreaseIndent(); + } + write("],"); + } + function emitExecute(node, startIndex) { + write("execute: function() {"); + increaseIndent(); + writeLine(); + for (var i = startIndex; i < node.statements.length; ++i) { + var statement = node.statements[i]; + switch (statement.kind) { + case 213: + case 222: + continue; + case 228: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 221: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + continue; + } + default: + writeLine(); + emit(statement); + } + } + decreaseIndent(); + writeLine(); + write("}"); + } + function emitSystemModule(node) { + collectExternalModuleInfo(node); + ts.Debug.assert(!exportFunctionForFile); + exportFunctionForFile = makeUniqueName("exports"); + writeLine(); + write("System.register("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + write("["); + var groupIndices = {}; + var dependencyGroups = []; + for (var i = 0; i < externalImports.length; ++i) { + var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } + if (i !== 0) { + write(", "); + } + write(text); + } + write("], function(" + exportFunctionForFile + ") {"); + writeLine(); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitSystemModuleBody(node, dependencyGroups, startIndex); + decreaseIndent(); + writeLine(); + write("});"); + } + function getAMDDependencyNames(node, includeNonAmdDependencies) { + var aliasedModuleNames = []; + var unaliasedModuleNames = []; + var importAliasNames = []; + for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { + var amdDependency = _b[_a]; + if (amdDependency.name) { + aliasedModuleNames.push("\"" + amdDependency.path + "\""); + importAliasNames.push(amdDependency.name); + } + else { + unaliasedModuleNames.push("\"" + amdDependency.path + "\""); + } + } + for (var _c = 0; _c < externalImports.length; _c++) { + var importNode = externalImports[_c]; + var externalModuleName = getExternalModuleNameText(importNode); + var importAliasName = getLocalNameForExternalImport(importNode); + if (includeNonAmdDependencies && importAliasName) { + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(importAliasName); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + function emitAMDDependencies(node, includeNonAmdDependencies) { + var dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); + emitAMDDependencyList(dependencyNames); + write(", "); + emitAMDFactoryHeader(dependencyNames); + } + function emitAMDDependencyList(_a) { + var aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames; + write("[\"require\", \"exports\""); + if (aliasedModuleNames.length) { + write(", "); + write(aliasedModuleNames.join(", ")); + } + if (unaliasedModuleNames.length) { + write(", "); + write(unaliasedModuleNames.join(", ")); + } + write("]"); + } + function emitAMDFactoryHeader(_a) { + var importAliasNames = _a.importAliasNames; + write("function (require, exports"); + if (importAliasNames.length) { + write(", "); + write(importAliasNames.join(", ")); + } + write(") {"); + } + function emitAMDModule(node) { + emitEmitHelpers(node); + collectExternalModuleInfo(node); + writeLine(); + write("define("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + emitAMDDependencies(node, true); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitCommonJSModule(node) { + var startIndex = emitDirectivePrologues(node.statements, false); + emitEmitHelpers(node); + collectExternalModuleInfo(node); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(false); + } + function emitUMDModule(node) { + emitEmitHelpers(node); + collectExternalModuleInfo(node); + var dependencyNames = getAMDDependencyNames(node, false); + writeLines("(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define("); + emitAMDDependencyList(dependencyNames); + write(", factory);"); + writeLines(" }\n})("); + emitAMDFactoryHeader(dependencyNames); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitES6Module(node) { + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + var startIndex = emitDirectivePrologues(node.statements, false); + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + } + function emitExportEquals(emitAsReturn) { + if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { + writeLine(); + emitStart(exportEquals); + write(emitAsReturn ? "return " : "module.exports = "); + emit(exportEquals.expression); + write(";"); + emitEnd(exportEquals); + } + } + function emitJsxElement(node) { + switch (compilerOptions.jsx) { + case 2: + jsxEmitReact(node); + break; + case 1: + default: + jsxEmitPreserve(node); + break; + } + } + function trimReactWhitespaceAndApplyEntities(node) { + var result = undefined; + var text = ts.getTextOfNode(node, true); + var firstNonWhitespace = 0; + var lastNonWhitespace = -1; + for (var i = 0; i < text.length; i++) { + var c = text.charCodeAt(i); + if (ts.isLineBreak(c)) { + if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { + var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); + } + firstNonWhitespace = -1; + } + else if (!ts.isWhiteSpace(c)) { + lastNonWhitespace = i; + if (firstNonWhitespace === -1) { + firstNonWhitespace = i; + } + } + } + if (firstNonWhitespace !== -1) { + var part = text.substr(firstNonWhitespace); + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); + } + if (result) { + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); + } + return result; + } + function getTextToEmit(node) { + switch (compilerOptions.jsx) { + case 2: + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { + return undefined; + } + else { + return text; + } + case 1: + default: + return ts.getTextOfNode(node, true); + } + } + function emitJsxText(node) { + switch (compilerOptions.jsx) { + case 2: + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); + break; + case 1: + default: + writer.writeLiteral(ts.getTextOfNode(node, true)); + break; + } + } + function emitJsxExpression(node) { + if (node.expression) { + switch (compilerOptions.jsx) { + case 1: + default: + write("{"); + emit(node.expression); + write("}"); + break; + case 2: + emit(node.expression); + break; + } + } + } + function emitDirectivePrologues(statements, startWithNewLine) { + for (var i = 0; i < statements.length; ++i) { + if (ts.isPrologueDirective(statements[i])) { + if (startWithNewLine || i > 0) { + writeLine(); + } + emit(statements[i]); + } + else { + return i; + } + } + return statements.length; + } + function writeLines(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 emitEmitHelpers(node) { + if (!compilerOptions.noEmitHelpers) { + if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { + writeLines(extendsHelper); + extendsEmitted = true; + } + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16) { + writeLines(decorateHelper); + if (compilerOptions.emitDecoratorMetadata) { + writeLines(metadataHelper); + } + decorateEmitted = true; + } + if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32) { + writeLines(paramHelper); + paramEmitted = true; + } + if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64) { + writeLines(awaiterHelper); + awaiterEmitted = true; + } + } + } + function emitSourceFileNode(node) { + writeLine(); + emitShebang(); + emitDetachedComments(node); + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1]; + emitModule(node); + } + else { + var startIndex = emitDirectivePrologues(node.statements, false); + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + } + emitLeadingComments(node.endOfFileToken); + } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2) { + return emitCommentsOnNotEmittedNode(node); + } + if (isSpecializedCommentHandling(node)) { + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } + function emitNodeWithoutSourceMap(node) { + if (node) { + emitJavaScriptWorker(node); + } + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + case 215: + case 213: + case 222: + case 221: + case 216: + case 227: + return true; + } + } + function shouldEmitLeadingAndTrailingComments(node) { + switch (node.kind) { + case 193: + return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); + case 218: + return shouldEmitModuleDeclaration(node); + case 217: + return shouldEmitEnumDeclaration(node); + } + ts.Debug.assert(!isSpecializedCommentHandling(node)); + if (node.kind !== 192 && + node.parent && + node.parent.kind === 174 && + node.parent.body === node && + compilerOptions.target <= 1) { + return false; + } + return true; + } + function emitJavaScriptWorker(node) { + switch (node.kind) { + case 69: + return emitIdentifier(node); + case 138: + return emitParameter(node); + case 143: + case 142: + return emitMethod(node); + case 145: + case 146: + return emitAccessor(node); + case 97: + return emitThis(node); + case 95: + return emitSuper(node); + case 93: + return write("null"); + case 99: + return write("true"); + case 84: + return write("false"); + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + return emitLiteral(node); + case 183: + return emitTemplateExpression(node); + case 190: + return emitTemplateSpan(node); + case 233: + case 234: + return emitJsxElement(node); + case 236: + return emitJsxText(node); + case 240: + return emitJsxExpression(node); + case 135: + return emitQualifiedName(node); + case 161: + return emitObjectBindingPattern(node); + case 162: + return emitArrayBindingPattern(node); + case 163: + return emitBindingElement(node); + case 164: + return emitArrayLiteral(node); + case 165: + return emitObjectLiteral(node); + case 245: + return emitPropertyAssignment(node); + case 246: + return emitShorthandPropertyAssignment(node); + case 136: + return emitComputedPropertyName(node); + case 166: + return emitPropertyAccess(node); + case 167: + return emitIndexedAccess(node); + case 168: + return emitCallExpression(node); + case 169: + return emitNewExpression(node); + case 170: + return emitTaggedTemplateExpression(node); + case 171: + return emit(node.expression); + case 189: + return emit(node.expression); + case 172: + return emitParenExpression(node); + case 213: + case 173: + case 174: + return emitFunctionDeclaration(node); + case 175: + return emitDeleteExpression(node); + case 176: + return emitTypeOfExpression(node); + case 177: + return emitVoidExpression(node); + case 178: + return emitAwaitExpression(node); + case 179: + return emitPrefixUnaryExpression(node); + case 180: + return emitPostfixUnaryExpression(node); + case 181: + return emitBinaryExpression(node); + case 182: + return emitConditionalExpression(node); + case 185: + return emitSpreadElementExpression(node); + case 184: + return emitYieldExpression(node); + case 187: + return; + case 192: + case 219: + return emitBlock(node); + case 193: + return emitVariableStatement(node); + case 194: + return write(";"); + case 195: + return emitExpressionStatement(node); + case 196: + return emitIfStatement(node); + case 197: + return emitDoStatement(node); + case 198: + return emitWhileStatement(node); + case 199: + return emitForStatement(node); + case 201: + case 200: + return emitForInOrForOfStatement(node); + case 202: + case 203: + return emitBreakOrContinueStatement(node); + case 204: + return emitReturnStatement(node); + case 205: + return emitWithStatement(node); + case 206: + return emitSwitchStatement(node); + case 241: + case 242: + return emitCaseOrDefaultClause(node); + case 207: + return emitLabelledStatement(node); + case 208: + return emitThrowStatement(node); + case 209: + return emitTryStatement(node); + case 244: + return emitCatchClause(node); + case 210: + return emitDebuggerStatement(node); + case 211: + return emitVariableDeclaration(node); + case 186: + return emitClassExpression(node); + case 214: + return emitClassDeclaration(node); + case 215: + return emitInterfaceDeclaration(node); + case 217: + return emitEnumDeclaration(node); + case 247: + return emitEnumMember(node); + case 218: + return emitModuleDeclaration(node); + case 222: + return emitImportDeclaration(node); + case 221: + return emitImportEqualsDeclaration(node); + case 228: + return emitExportDeclaration(node); + case 227: + return emitExportAssignment(node); + case 248: + return emitSourceFileNode(node); + } + } + function hasDetachedComments(pos) { + return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; + } + function getLeadingCommentsWithoutDetachedComments() { + var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); + if (detachedCommentsInfo.length - 1) { + detachedCommentsInfo.pop(); + } + else { + detachedCommentsInfo = undefined; + } + return leadingComments; + } + function isPinnedComments(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; + } + function isTripleSlashComment(comment) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 47) { + var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); + return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || + textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? + true : false; + } + return false; + } + function getLeadingCommentsToEmit(node) { + if (node.parent) { + if (node.parent.kind === 248 || node.pos !== node.parent.pos) { + if (hasDetachedComments(node.pos)) { + return getLeadingCommentsWithoutDetachedComments(); + } + else { + return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); + } + } + } + } + function getTrailingCommentsToEmit(node) { + if (node.parent) { + if (node.parent.kind === 248 || node.end !== node.parent.end) { + return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); + } + } + } + function emitCommentsOnNotEmittedNode(node) { + emitLeadingCommentsWorker(node, false); + } + function emitLeadingComments(node) { + return emitLeadingCommentsWorker(node, true); + } + function emitLeadingCommentsWorker(node, isEmittedNode) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (isEmittedNode) { + leadingComments = getLeadingCommentsToEmit(node); + } + else { + if (node.pos === 0) { + leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); + } + } + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + } + function emitTrailingComments(node) { + if (compilerOptions.removeComments) { + return; + } + var trailingComments = getTrailingCommentsToEmit(node); + ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); + } + function emitTrailingCommentsOfPosition(pos) { + if (compilerOptions.removeComments) { + return; + } + var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); + ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment); + } + function emitLeadingCommentsOfPositionWorker(pos) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (hasDetachedComments(pos)) { + leadingComments = getLeadingCommentsWithoutDetachedComments(); + } + else { + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); + } + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + } + function emitDetachedComments(node) { + var leadingComments; + if (compilerOptions.removeComments) { + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + } + } + else { + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment; + ts.forEach(leadingComments, function (comment) { + if (lastComment) { + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); + if (commentLine >= lastCommentLine + 2) { + return detachedComments; + } + } + detachedComments.push(comment); + lastComment = comment; + }); + if (detachedComments.length) { + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); + var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); + var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); + } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; + } + } + } + } + } + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); + } + } + var _a; + } + function emitFile(jsFilePath, sourceFile) { + emitJavaScript(jsFilePath, sourceFile); + if (compilerOptions.declaration) { + ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); + } + } + } + ts.emitFiles = emitFiles; })(ts || (ts = {})); var ts; (function (ts) { @@ -29369,11 +29890,11 @@ var ts; if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { var failedLookupLocations = []; var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolvedFileName = loadNodeModuleFromFile(candidate, false, failedLookupLocations, host); + var resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (resolvedFileName) { return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; } - resolvedFileName = loadNodeModuleFromDirectory(candidate, false, failedLookupLocations, host); + resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); return resolvedFileName ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; @@ -29383,13 +29904,8 @@ var ts; } } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { - if (loadOnlyDts) { - return tryLoad(".d.ts"); - } - else { - return ts.forEach(ts.supportedExtensions, tryLoad); - } + function loadNodeModuleFromFile(candidate, failedLookupLocation, host) { + return ts.forEach(ts.supportedJsExtensions, tryLoad); function tryLoad(ext) { var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; if (host.fileExists(fileName)) { @@ -29401,7 +29917,7 @@ var ts; } } } - function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + function loadNodeModuleFromDirectory(candidate, failedLookupLocation, host) { var packageJsonPath = ts.combinePaths(candidate, "package.json"); if (host.fileExists(packageJsonPath)) { var jsonContent; @@ -29413,7 +29929,7 @@ var ts; jsonContent = { typings: undefined }; } if (jsonContent.typings) { - var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); if (result) { return result; } @@ -29422,7 +29938,7 @@ var ts; else { failedLookupLocation.push(packageJsonPath); } - return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), failedLookupLocation, host); } function loadModuleFromNodeModules(moduleName, directory, host) { var failedLookupLocations = []; @@ -29432,11 +29948,11 @@ var ts; if (baseName !== "node_modules") { var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var result = loadNodeModuleFromFile(candidate, true, failedLookupLocations, host); + var result = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; } - result = loadNodeModuleFromDirectory(candidate, true, failedLookupLocations, host); + result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; } @@ -29454,16 +29970,17 @@ var ts; return i === 0 || (i === 1 && name.charCodeAt(0) === 46); } function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - if (moduleName.indexOf('!') != -1) { + if (moduleName.indexOf("!") != -1) { return { resolvedModule: undefined, failedLookupLocations: [] }; } var searchPath = ts.getDirectoryPath(containingFile); var searchName; var failedLookupLocations = []; var referencedSourceFile; + var extensions = compilerOptions.allowNonTsExtensions ? ts.supportedJsExtensions : ts.supportedExtensions; while (true) { searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + referencedSourceFile = ts.forEach(extensions, function (extension) { if (extension === ".tsx" && !compilerOptions.jsx) { return undefined; } @@ -29763,7 +30280,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - return filesByName.get(fileName); + return filesByName.get(fileName) || filesByName.get(ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory())); } function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { @@ -29849,13 +30366,18 @@ var ts; if (file.imports) { return; } + var isJavaScriptFile = ts.isSourceFileJavaScript(file); var imports; for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var node = _a[_i]; + collect(node, true); + } + file.imports = imports || emptyArray; + function collect(node, allowRelativeModuleNames) { switch (node.kind) { - case 220: - case 219: - case 226: + case 222: + case 221: + case 228: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -29863,24 +30385,35 @@ var ts; if (!moduleNameExpr.text) { break; } - (imports || (imports = [])).push(moduleNameExpr); + if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { + (imports || (imports = [])).push(moduleNameExpr); + } break; - case 216: - if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { - ts.forEachChild(node.body, function (node) { - if (ts.isExternalModuleImportEqualsDeclaration(node) && - ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9) { - var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); - if (moduleName) { - (imports || (imports = [])).push(moduleName); + case 168: + if (isJavaScriptFile && ts.isRequireCall(node)) { + var jsImports = node.arguments; + if (jsImports) { + imports = (imports || []); + for (var i = 0; i < jsImports.length; i++) { + if (jsImports[i].kind === 9) { + imports.push(jsImports[i]); } } + } + } + break; + case 218: + if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { + ts.forEachChild(node.body, function (node) { + collect(node, false); }); } break; } + if (ts.isSourceFileJavaScript(file)) { + ts.forEachChild(node, function (node) { return collect(node, allowRelativeModuleNames); }); + } } - file.imports = imports || emptyArray; } function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; @@ -29923,48 +30456,46 @@ var ts; } } function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - if (filesByName.contains(canonicalName)) { - return getSourceFileFromCache(fileName, canonicalName, false); + if (filesByName.contains(fileName)) { + return getSourceFileFromCache(fileName, false); } - else { - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); - var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); - if (filesByName.contains(canonicalAbsolutePath)) { - return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); + var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); + if (filesByName.contains(normalizedAbsolutePath)) { + var file_1 = getSourceFileFromCache(normalizedAbsolutePath, true); + filesByName.set(fileName, file_1); + return file_1; + } + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }); - filesByName.set(canonicalName, file); - if (file) { - skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - filesByName.set(canonicalAbsolutePath, file); - var basePath = ts.getDirectoryPath(fileName); - if (!options.noResolve) { - processReferencedFiles(file, basePath); - } - processImportedModules(file, basePath); - if (isDefaultLib) { - file.isDefaultLib = true; - files.unshift(file); - } - else { - files.push(file); - } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + }); + filesByName.set(fileName, file); + if (file) { + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + filesByName.set(normalizedAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); + if (!options.noResolve) { + processReferencedFiles(file, basePath); + } + processImportedModules(file, basePath); + if (isDefaultLib) { + file.isDefaultLib = true; + files.unshift(file); + } + else { + files.push(file); } - return file; } - function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) { - var file = filesByName.get(canonicalName); + return file; + function getSourceFileFromCache(fileName, useAbsolutePath) { + var file = filesByName.get(fileName); if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; - if (canonicalName !== sourceFileName) { + if (ts.normalizeSlashes(fileName) !== ts.normalizeSlashes(sourceFileName)) { if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); } @@ -30125,8 +30656,8 @@ var ts; var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } - if (options.module && languageVersion >= 2) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); + if (options.module === 5 && languageVersion < 2) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower)); } if (options.outDir || options.sourceRoot || @@ -30160,10 +30691,6 @@ var ts; !options.experimentalDecorators) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } - if (options.experimentalAsyncFunctions && - options.target !== 2) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); - } } } ts.createProgram = createProgram; @@ -30240,11 +30767,12 @@ var ts; "commonjs": 1, "amd": 2, "system": 4, - "umd": 3 + "umd": 3, + "es6": 5 }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_or_umd, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6 }, { name: "newLine", @@ -30385,11 +30913,6 @@ var ts; type: "boolean", description: ts.Diagnostics.Watch_input_files }, - { - name: "experimentalAsyncFunctions", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_async_functions - }, { name: "experimentalDecorators", type: "boolean", @@ -30576,6 +31099,9 @@ var ts; } if (opt.isFilePath) { value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } } options[opt.name] = value; } @@ -30604,20 +31130,20 @@ var ts; var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); for (var i = 0; i < sysFiles.length; i++) { - var name_27 = sysFiles[i]; - if (ts.fileExtensionIs(name_27, ".d.ts")) { - var baseName = name_27.substr(0, name_27.length - ".d.ts".length); + var name_28 = sysFiles[i]; + if (ts.fileExtensionIs(name_28, ".d.ts")) { + var baseName = name_28.substr(0, name_28.length - ".d.ts".length); if (!ts.contains(sysFiles, baseName + ".tsx") && !ts.contains(sysFiles, baseName + ".ts")) { - fileNames.push(name_27); + fileNames.push(name_28); } } - else if (ts.fileExtensionIs(name_27, ".ts")) { - if (!ts.contains(sysFiles, name_27 + "x")) { - fileNames.push(name_27); + else if (ts.fileExtensionIs(name_28, ".ts")) { + if (!ts.contains(sysFiles, name_28 + "x")) { + fileNames.push(name_28); } } else { - fileNames.push(name_27); + fileNames.push(name_28); } } } @@ -30701,6 +31227,15 @@ var ts; reportDiagnostic(diagnostics[i]); } } + function reportWatchDiagnostic(diagnostic) { + var output = new Date().toLocaleTimeString() + " - "; + if (diagnostic.file) { + var loc = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); + output += diagnostic.file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + "): "; + } + output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine) + ts.sys.newLine; + ts.sys.write(output); + } function padLeft(s, length) { while (s.length < length) { s = " " + s; @@ -30794,7 +31329,7 @@ var ts; if (configFileName) { var result = ts.readConfigFile(configFileName, ts.sys.readFile); if (result.error) { - reportDiagnostic(result.error); + reportWatchDiagnostic(result.error); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } var configObject = result.config; @@ -30819,7 +31354,7 @@ var ts; return ts.sys.exit(compileResult.exitStatus); } setCachedProgram(compileResult.program); - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Compilation_complete_Watching_for_file_changes)); + reportWatchDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Compilation_complete_Watching_for_file_changes)); } function getSourceFile(fileName, languageVersion, onError) { if (cachedProgram) { @@ -30830,7 +31365,7 @@ var ts; } var sourceFile = hostGetSourceFile(fileName, languageVersion, onError); if (sourceFile && compilerOptions.watch) { - sourceFile.fileWatcher = ts.sys.watchFile(sourceFile.fileName, function () { return sourceFileChanged(sourceFile); }); + sourceFile.fileWatcher = ts.sys.watchFile(sourceFile.fileName, function (fileName, removed) { return sourceFileChanged(sourceFile, removed); }); } return sourceFile; } @@ -30848,9 +31383,15 @@ var ts; } cachedProgram = program; } - function sourceFileChanged(sourceFile) { + function sourceFileChanged(sourceFile, removed) { sourceFile.fileWatcher.close(); sourceFile.fileWatcher = undefined; + if (removed) { + var index = rootFileNames.indexOf(sourceFile.fileName); + if (index >= 0) { + rootFileNames.splice(index, 1); + } + } startTimer(); } function configFileChanged() { @@ -30865,7 +31406,7 @@ var ts; } function recompile() { timerHandle = undefined; - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation)); + reportWatchDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation)); performCompilation(); } } @@ -30993,7 +31534,7 @@ var ts; } function writeConfigFile(options, fileNames) { var currentDirectory = ts.sys.getCurrentDirectory(); - var file = ts.combinePaths(currentDirectory, 'tsconfig.json'); + var file = ts.combinePaths(currentDirectory, "tsconfig.json"); if (ts.sys.fileExists(file)) { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file)); } @@ -31013,10 +31554,10 @@ var ts; function serializeCompilerOptions(options) { var result = {}; var optionsNameMap = ts.getOptionNameMap().optionNameMap; - for (var name_28 in options) { - if (ts.hasProperty(options, name_28)) { - var value = options[name_28]; - switch (name_28) { + for (var name_29 in options) { + if (ts.hasProperty(options, name_29)) { + var value = options[name_29]; + switch (name_29) { case "init": case "watch": case "version": @@ -31024,17 +31565,17 @@ var ts; case "project": break; default: - var optionDefinition = optionsNameMap[name_28.toLowerCase()]; + var optionDefinition = optionsNameMap[name_29.toLowerCase()]; if (optionDefinition) { if (typeof optionDefinition.type === "string") { - result[name_28] = value; + result[name_29] = value; } else { var typeMap = optionDefinition.type; for (var key in typeMap) { if (ts.hasProperty(typeMap, key)) { if (typeMap[key] === value) - result[name_28] = key; + result[name_29] = key; } } } diff --git a/lib/tsserver.js b/lib/tsserver.js index 82199e1222d8c..0368e826f1366 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -410,8 +410,11 @@ var ts; } ts.chainDiagnosticMessages = chainDiagnosticMessages; function concatenateDiagnosticMessageChains(headChain, tailChain) { - Debug.assert(!headChain.next); - headChain.next = tailChain; + var lastChain = headChain; + while (lastChain.next) { + lastChain = lastChain.next; + } + lastChain.next = tailChain; return headChain; } ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; @@ -650,6 +653,7 @@ var ts; } ts.fileExtensionIs = fileExtensionIs; ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; + ts.supportedJsExtensions = ts.supportedExtensions.concat(".js", ".jsx"); var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { @@ -949,10 +953,14 @@ var ts; close: function () { _fs.unwatchFile(fileName, fileChanged); } }; function fileChanged(curr, prev) { + if (curr.mtime.getTime() === 0) { + callback(fileName, true); + return; + } if (+curr.mtime <= +prev.mtime) { return; } - callback(fileName); + callback(fileName, false); } }, resolvePath: function (path) { @@ -1050,7 +1058,7 @@ var ts; Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum member must have initializer." }, _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, - 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." }, + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In ambient enum declarations member initializer must be constant expression." }, 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_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, @@ -1138,7 +1146,7 @@ var ts; 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." }, - An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, + An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1183, 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." }, @@ -1156,10 +1164,9 @@ var ts; 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." }, - 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_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' 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." }, + Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." }, + Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." }, + Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es6' when targeting 'ES5' or lower." }, 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." }, Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, @@ -1188,10 +1195,6 @@ var ts; An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, - Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning: { code: 1236, category: ts.DiagnosticCategory.Error, key: "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning." }, - with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, - await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, - Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, @@ -1202,6 +1205,10 @@ var ts; _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." }, Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." }, Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method '{0}' cannot have an implementation because it is marked abstract." }, + with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, + await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, + Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, + can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "'=' can only be used in an object literal property inside a destructuring assignment." }, 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." }, @@ -1326,7 +1333,7 @@ var ts; 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_namespace_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 namespace declaration cannot be in a different file from a class or function with which it is merged" }, A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules." }, + Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules or namespaces." }, Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient 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}'" }, @@ -1414,6 +1421,9 @@ var ts; yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." }, + A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A 'this' type is available only in a non-static member of a class or interface." }, + The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, + A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A module cannot have multiple default exports." }, JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -1514,7 +1524,7 @@ var ts; Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, - A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, 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." }, @@ -1526,7 +1536,7 @@ var ts; 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_amd_system_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'" }, + Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es6'" }, 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." }, @@ -1547,7 +1557,7 @@ var ts; 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_amd_system_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'." }, + Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es6'." }, 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}'." }, @@ -1568,7 +1578,6 @@ var ts; Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, - Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, @@ -1615,81 +1624,83 @@ var ts; Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" }, + An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, + A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." } }; })(ts || (ts = {})); var ts; (function (ts) { function tokenIsIdentifierOrKeyword(token) { - return token >= 67; + return token >= 69; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = { - "abstract": 113, - "any": 115, - "as": 114, - "boolean": 118, - "break": 68, - "case": 69, - "catch": 70, - "class": 71, - "continue": 73, - "const": 72, - "constructor": 119, - "debugger": 74, - "declare": 120, - "default": 75, - "delete": 76, - "do": 77, - "else": 78, - "enum": 79, - "export": 80, - "extends": 81, - "false": 82, - "finally": 83, - "for": 84, - "from": 131, - "function": 85, - "get": 121, - "if": 86, - "implements": 104, - "import": 87, - "in": 88, - "instanceof": 89, - "interface": 105, - "is": 122, - "let": 106, - "module": 123, - "namespace": 124, - "new": 90, - "null": 91, - "number": 126, - "package": 107, - "private": 108, - "protected": 109, - "public": 110, - "require": 125, - "return": 92, - "set": 127, - "static": 111, - "string": 128, - "super": 93, - "switch": 94, - "symbol": 129, - "this": 95, - "throw": 96, - "true": 97, - "try": 98, - "type": 130, - "typeof": 99, - "var": 100, - "void": 101, - "while": 102, - "with": 103, - "yield": 112, - "async": 116, - "await": 117, - "of": 132, + "abstract": 115, + "any": 117, + "as": 116, + "boolean": 120, + "break": 70, + "case": 71, + "catch": 72, + "class": 73, + "continue": 75, + "const": 74, + "constructor": 121, + "debugger": 76, + "declare": 122, + "default": 77, + "delete": 78, + "do": 79, + "else": 80, + "enum": 81, + "export": 82, + "extends": 83, + "false": 84, + "finally": 85, + "for": 86, + "from": 133, + "function": 87, + "get": 123, + "if": 88, + "implements": 106, + "import": 89, + "in": 90, + "instanceof": 91, + "interface": 107, + "is": 124, + "let": 108, + "module": 125, + "namespace": 126, + "new": 92, + "null": 93, + "number": 128, + "package": 109, + "private": 110, + "protected": 111, + "public": 112, + "require": 127, + "return": 94, + "set": 129, + "static": 113, + "string": 130, + "super": 95, + "switch": 96, + "symbol": 131, + "this": 97, + "throw": 98, + "true": 99, + "try": 100, + "type": 132, + "typeof": 101, + "var": 102, + "void": 103, + "while": 104, + "with": 105, + "yield": 114, + "async": 118, + "await": 119, + "of": 134, "{": 15, "}": 16, "(": 17, @@ -1711,37 +1722,39 @@ var ts; "=>": 34, "+": 35, "-": 36, + "**": 38, "*": 37, - "/": 38, - "%": 39, - "++": 40, - "--": 41, - "<<": 42, + "/": 39, + "%": 40, + "++": 41, + "--": 42, + "<<": 43, ">": 43, - ">>>": 44, - "&": 45, - "|": 46, - "^": 47, - "!": 48, - "~": 49, - "&&": 50, - "||": 51, - "?": 52, - ":": 53, - "=": 55, - "+=": 56, - "-=": 57, - "*=": 58, - "/=": 59, - "%=": 60, - "<<=": 61, - ">>=": 62, - ">>>=": 63, - "&=": 64, - "|=": 65, - "^=": 66, - "@": 54 + ">>": 44, + ">>>": 45, + "&": 46, + "|": 47, + "^": 48, + "!": 49, + "~": 50, + "&&": 51, + "||": 52, + "?": 53, + ":": 54, + "=": 56, + "+=": 57, + "-=": 58, + "*=": 59, + "**=": 60, + "/=": 61, + "%=": 62, + "<<=": 63, + ">>=": 64, + ">>>=": 65, + "&=": 66, + "|=": 67, + "^=": 68, + "@": 55 }; 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,]; @@ -2143,8 +2156,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 67 || token > 103; }, - isReservedWord: function () { return token >= 68 && token <= 103; }, + isIdentifier: function () { return token === 69 || token > 105; }, + isReservedWord: function () { return token >= 70 && token <= 105; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -2166,16 +2179,6 @@ var ts; onError(message, length || 0); } } - function isIdentifierStart(ch) { - return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || - ch === 36 || ch === 95 || - ch > 127 && isUnicodeIdentifierStart(ch, languageVersion); - } - function isIdentifierPart(ch) { - return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || - ch >= 48 && ch <= 57 || ch === 36 || ch === 95 || - ch > 127 && isUnicodeIdentifierPart(ch, languageVersion); - } function scanNumber() { var start = pos; while (isDigit(text.charCodeAt(pos))) @@ -2430,12 +2433,12 @@ var ts; var start = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (isIdentifierPart(ch)) { + if (isIdentifierPart(ch, languageVersion)) { pos++; } else if (ch === 92) { ch = peekUnicodeEscape(); - if (!(ch >= 0 && isIdentifierPart(ch))) { + if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } result += text.substring(start, pos); @@ -2458,7 +2461,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 67; + return token = 69; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -2537,7 +2540,7 @@ var ts; } return pos += 2, token = 31; } - return pos++, token = 48; + return pos++, token = 49; case 34: case 39: tokenValue = scanString(); @@ -2546,42 +2549,48 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 60; + return pos += 2, token = 62; } - return pos++, token = 39; + return pos++, token = 40; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 50; + return pos += 2, token = 51; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; + return pos += 2, token = 66; } - return pos++, token = 45; + return pos++, token = 46; case 40: return pos++, token = 17; case 41: return pos++, token = 18; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; + return pos += 2, token = 59; + } + if (text.charCodeAt(pos + 1) === 42) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 60; + } + return pos += 2, token = 38; } return pos++, token = 37; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 40; + return pos += 2, token = 41; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 56; + return pos += 2, token = 57; } return pos++, token = 35; case 44: return pos++, token = 24; case 45: if (text.charCodeAt(pos + 1) === 45) { - return pos += 2, token = 41; + return pos += 2, token = 42; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; + return pos += 2, token = 58; } return pos++, token = 36; case 46: @@ -2636,9 +2645,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; + return pos += 2, token = 61; } - return pos++, token = 38; + return pos++, token = 39; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -2686,7 +2695,7 @@ var ts; tokenValue = "" + scanNumber(); return token = 8; case 58: - return pos++, token = 53; + return pos++, token = 54; case 59: return pos++, token = 23; case 60: @@ -2701,14 +2710,16 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 61; + return pos += 3, token = 63; } - return pos += 2, token = 42; + return pos += 2, token = 43; } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 28; } - if (text.charCodeAt(pos + 1) === 47 && languageVariant === 1) { + if (languageVariant === 1 && + text.charCodeAt(pos + 1) === 47 && + text.charCodeAt(pos + 2) !== 42) { return pos += 2, token = 26; } return pos++, token = 25; @@ -2731,7 +2742,7 @@ var ts; if (text.charCodeAt(pos + 1) === 62) { return pos += 2, token = 34; } - return pos++, token = 55; + return pos++, token = 56; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2744,35 +2755,35 @@ var ts; } return pos++, token = 27; case 63: - return pos++, token = 52; + return pos++, token = 53; case 91: return pos++, token = 19; case 93: return pos++, token = 20; case 94: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 66; + return pos += 2, token = 68; } - return pos++, token = 47; + return pos++, token = 48; case 123: return pos++, token = 15; case 124: if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 51; + return pos += 2, token = 52; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 65; + return pos += 2, token = 67; } - return pos++, token = 46; + return pos++, token = 47; case 125: return pos++, token = 16; case 126: - return pos++, token = 49; + return pos++, token = 50; case 64: - return pos++, token = 54; + return pos++, token = 55; case 92: var cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); @@ -2780,9 +2791,9 @@ var ts; error(ts.Diagnostics.Invalid_character); return pos++, token = 0; default: - if (isIdentifierStart(ch)) { + if (isIdentifierStart(ch, languageVersion)) { pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos))) + while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) pos++; tokenValue = text.substring(tokenPos, pos); if (ch === 92) { @@ -2809,14 +2820,14 @@ var ts; if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 63; + return pos += 3, token = 65; } - return pos += 2, token = 44; + return pos += 2, token = 45; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 64; } - return pos++, token = 43; + return pos++, token = 44; } if (text.charCodeAt(pos) === 61) { return pos++, token = 29; @@ -2825,7 +2836,7 @@ var ts; return token; } function reScanSlashToken() { - if (token === 38 || token === 59) { + if (token === 39 || token === 61) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -2859,7 +2870,7 @@ var ts; } p++; } - while (p < end && isIdentifierPart(text.charCodeAt(p))) { + while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { p++; } pos = p; @@ -2902,14 +2913,14 @@ var ts; break; } } - return token = 234; + return token = 236; } function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) { + if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { pos++; } else { @@ -3044,11 +3055,12 @@ var ts; "commonjs": 1, "amd": 2, "system": 4, - "umd": 3 + "umd": 3, + "es6": 5 }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_or_umd, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6 }, { name: "newLine", @@ -3189,11 +3201,6 @@ var ts; type: "boolean", description: ts.Diagnostics.Watch_input_files }, - { - name: "experimentalAsyncFunctions", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_async_functions - }, { name: "experimentalDecorators", type: "boolean", @@ -3380,6 +3387,9 @@ var ts; } if (opt.isFilePath) { value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } } options[opt.name] = value; } @@ -3463,7 +3473,8 @@ var ts; increaseIndent: function () { }, decreaseIndent: function () { }, clear: function () { return str = ""; }, - trackSymbol: function () { } + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } }; } return stringWriters.pop(); @@ -3525,7 +3536,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 246) { + while (node && node.kind !== 248) { node = node.parent; } return node; @@ -3616,15 +3627,15 @@ var ts; return current; } switch (current.kind) { - case 246: + case 248: + case 220: + case 244: case 218: - case 242: - case 216: - case 197: - case 198: case 199: + case 200: + case 201: return current; - case 190: + case 192: if (!isFunctionLike(current.parent)) { return current; } @@ -3635,9 +3646,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 209 && + declaration.kind === 211 && declaration.parent && - declaration.parent.kind === 242; + declaration.parent.kind === 244; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3673,22 +3684,22 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 246: + case 248: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 209: - case 161: - case 212: - case 184: - case 213: - case 216: - case 215: - case 245: case 211: - case 171: + case 163: + case 214: + case 186: + case 215: + case 218: + case 217: + case 247: + case 213: + case 173: errorNode = node.name; break; } @@ -3705,16 +3716,20 @@ var ts; return file.externalModuleIndicator !== undefined; } ts.isExternalModule = isExternalModule; + function isExternalOrCommonJsModule(file) { + return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; + } + ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isDeclarationFile(file) { return (file.flags & 8192) !== 0; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 215 && isConst(node); + return node.kind === 217 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 161 || isBindingPattern(node))) { + while (node && (node.kind === 163 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3722,14 +3737,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 209) { + if (node.kind === 211) { node = node.parent; } - if (node && node.kind === 210) { + if (node && node.kind === 212) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 191) { + if (node && node.kind === 193) { flags |= node.flags; } return flags; @@ -3744,7 +3759,7 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 193 && node.expression.kind === 9; + return node.kind === 195 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -3752,7 +3767,7 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - var commentRanges = (node.kind === 136 || node.kind === 135) ? + var commentRanges = (node.kind === 138 || node.kind === 137) ? ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : getLeadingCommentRangesOfNode(node, sourceFileOfNode); return ts.filter(commentRanges, isJsDocComment); @@ -3766,68 +3781,69 @@ var ts; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (149 <= node.kind && node.kind <= 158) { + if (151 <= node.kind && node.kind <= 160) { return true; } switch (node.kind) { - case 115: - case 126: + case 117: case 128: - case 118: - case 129: + case 130: + case 120: + case 131: return true; - case 101: - return node.parent.kind !== 175; + case 103: + return node.parent.kind !== 177; case 9: - return node.parent.kind === 136; - case 186: + return node.parent.kind === 138; + case 188: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 67: - if (node.parent.kind === 133 && node.parent.right === node) { + case 69: + if (node.parent.kind === 135 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 164 && node.parent.name === node) { + else if (node.parent.kind === 166 && node.parent.name === node) { node = node.parent; } - case 133: - case 164: - ts.Debug.assert(node.kind === 67 || node.kind === 133 || node.kind === 164, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 69 || node.kind === 135 || node.kind === 166, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 135: + case 166: + case 97: var parent_1 = node.parent; - if (parent_1.kind === 152) { + if (parent_1.kind === 154) { return false; } - if (149 <= parent_1.kind && parent_1.kind <= 158) { + if (151 <= parent_1.kind && parent_1.kind <= 160) { return true; } switch (parent_1.kind) { - case 186: + case 188: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 135: + case 137: return node === parent_1.constraint; - case 139: - case 138: - case 136: - case 209: - return node === parent_1.type; - case 211: - case 171: - case 172: - case 142: case 141: case 140: - case 143: - case 144: + case 138: + case 211: return node === parent_1.type; + case 213: + case 173: + case 174: + case 144: + case 143: + case 142: case 145: case 146: + return node === parent_1.type; case 147: + case 148: + case 149: return node === parent_1.type; - case 169: + case 171: return node === parent_1.type; - case 166: - case 167: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 168: + case 169: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 170: return false; } } @@ -3838,23 +3854,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 202: + case 204: return visitor(node); - case 218: - case 190: - case 194: - case 195: + case 220: + case 192: case 196: case 197: case 198: case 199: - case 203: - case 204: - case 239: - case 240: + case 200: + case 201: case 205: - case 207: + case 206: + case 241: case 242: + case 207: + case 209: + case 244: return ts.forEachChild(node, traverse); } } @@ -3864,23 +3880,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 182: + case 184: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } + case 217: case 215: - case 213: + case 218: case 216: case 214: - case 212: - case 184: + case 186: return; default: if (isFunctionLike(node)) { var name_6 = node.name; - if (name_6 && name_6.kind === 134) { + if (name_6 && name_6.kind === 136) { traverse(name_6.expression); return; } @@ -3895,14 +3911,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 161: - case 245: - case 136: - case 243: - case 139: + case 163: + case 247: case 138: - case 244: - case 209: + case 245: + case 141: + case 140: + case 246: + case 211: return true; } } @@ -3910,29 +3926,29 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 143 || node.kind === 144); + return node && (node.kind === 145 || node.kind === 146); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 212 || node.kind === 184); + return node && (node.kind === 214 || node.kind === 186); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 142: - case 171: - case 211: - case 172: - case 141: - case 140: - case 143: case 144: + case 173: + case 213: + case 174: + case 143: + case 142: case 145: case 146: case 147: - case 150: - case 151: + case 148: + case 149: + case 152: + case 153: return true; } } @@ -3941,24 +3957,24 @@ var ts; ts.isFunctionLike = isFunctionLike; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 141: - case 140: - case 142: case 143: + case 142: case 144: - case 211: - case 171: + case 145: + case 146: + case 213: + case 173: return true; } return false; } ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 190 && isFunctionLike(node.parent); + return node && node.kind === 192 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 141 && node.parent.kind === 163; + return node && node.kind === 143 && node.parent.kind === 165; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -3986,36 +4002,39 @@ var ts; return undefined; } switch (node.kind) { - case 134: + case 136: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 137: - if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { + case 139: + if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 172: + case 174: if (!includeArrowFunctions) { continue; } - case 211: - case 171: - case 216: - case 139: - case 138: + case 213: + case 173: + case 218: case 141: case 140: - case 142: case 143: + case 142: case 144: - case 215: - case 246: + case 145: + case 146: + case 147: + case 148: + case 149: + case 217: + case 248: return node; } } @@ -4027,33 +4046,33 @@ var ts; if (!node) return node; switch (node.kind) { - case 134: + case 136: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 137: - if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { + case 139: + if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 211: - case 171: - case 172: + case 213: + case 173: + case 174: if (!includeFunctions) { continue; } - case 139: - case 138: case 141: case 140: - case 142: case 143: + case 142: case 144: + case 145: + case 146: return node; } } @@ -4062,12 +4081,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 149: + case 151: return node.typeName; - case 186: + case 188: return node.expression; - case 67: - case 133: + case 69: + case 135: return node; } } @@ -4075,7 +4094,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 168) { + if (node.kind === 170) { return node.tag; } return node.expression; @@ -4083,40 +4102,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 212: + case 214: return true; - case 139: - return node.parent.kind === 212; - case 136: - return node.parent.body && node.parent.parent.kind === 212; - case 143: - case 144: case 141: - return node.body && node.parent.kind === 212; + return node.parent.kind === 214; + case 138: + return node.parent.body && node.parent.parent.kind === 214; + case 145: + case 146: + case 143: + return node.body && node.parent.kind === 214; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 212: + case 214: if (node.decorators) { return true; } return false; - case 139: - case 136: + case 141: + case 138: if (node.decorators) { return true; } return false; - case 143: + case 145: if (node.body && node.decorators) { return true; } return false; - case 141: - case 144: + case 143: + case 146: if (node.body && node.decorators) { return true; } @@ -4127,10 +4146,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 212: + case 214: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 141: - case 144: + case 143: + case 146: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -4140,95 +4159,105 @@ var ts; return nodeIsDecorated(node) || childIsDecorated(node); } ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; + function isPropertyAccessExpression(node) { + return node.kind === 166; + } + ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isElementAccessExpression(node) { + return node.kind === 167; + } + ts.isElementAccessExpression = isElementAccessExpression; function isExpression(node) { switch (node.kind) { case 95: case 93: - case 91: - case 97: - case 82: + case 99: + case 84: case 10: - case 162: - case 163: case 164: case 165: case 166: case 167: case 168: - case 187: case 169: case 170: + case 189: case 171: - case 184: case 172: - case 175: case 173: + case 186: case 174: case 177: - case 178: + case 175: + case 176: case 179: case 180: - case 183: case 181: - case 11: - case 185: - case 231: - case 232: case 182: + case 185: + case 183: + case 11: + case 187: + case 233: + case 234: + case 184: + case 178: return true; - case 133: - while (node.parent.kind === 133) { + case 135: + while (node.parent.kind === 135) { node = node.parent; } - return node.parent.kind === 152; - case 67: - if (node.parent.kind === 152) { + return node.parent.kind === 154; + case 69: + if (node.parent.kind === 154) { return true; } case 8: case 9: + case 97: var parent_2 = node.parent; switch (parent_2.kind) { - case 209: - case 136: - case 139: + case 211: case 138: + case 141: + case 140: + case 247: case 245: - case 243: - case 161: + case 163: return parent_2.initializer === node; - case 193: - case 194: case 195: case 196: - case 202: - case 203: + case 197: + case 198: case 204: - case 239: + case 205: + case 206: + case 241: + case 208: case 206: - case 204: return parent_2.expression === node; - case 197: + case 199: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 210) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 212) || forStatement.condition === node || forStatement.incrementor === node; - case 198: - case 199: + case 200: + case 201: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 212) || forInStatement.expression === node; - case 169: - case 187: + case 171: + case 189: return node === parent_2.expression; - case 188: + case 190: return node === parent_2.expression; - case 134: + case 136: return node === parent_2.expression; - case 137: - case 238: + case 139: + case 240: + case 239: return true; - case 186: + case 188: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -4239,6 +4268,10 @@ var ts; return false; } ts.isExpression = isExpression; + function isExternalModuleNameRelative(moduleName) { + return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); return moduleState === 1 || @@ -4246,7 +4279,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 219 && node.moduleReference.kind === 230; + return node.kind === 221 && node.moduleReference.kind === 232; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -4255,20 +4288,54 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 219 && node.moduleReference.kind !== 230; + return node.kind === 221 && node.moduleReference.kind !== 232; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; + function isSourceFileJavaScript(file) { + return isInJavaScriptFile(file); + } + ts.isSourceFileJavaScript = isSourceFileJavaScript; + function isInJavaScriptFile(node) { + return node && !!(node.parserContextFlags & 32); + } + ts.isInJavaScriptFile = isInJavaScriptFile; + function isRequireCall(expression) { + return expression.kind === 168 && + expression.expression.kind === 69 && + expression.expression.text === "require" && + expression.arguments.length === 1; + } + ts.isRequireCall = isRequireCall; + function isExportsPropertyAssignment(expression) { + return isInJavaScriptFile(expression) && + (expression.kind === 181) && + (expression.operatorToken.kind === 56) && + (expression.left.kind === 166) && + (expression.left.expression.kind === 69) && + ((expression.left.expression).text === "exports"); + } + ts.isExportsPropertyAssignment = isExportsPropertyAssignment; + function isModuleExportsAssignment(expression) { + return isInJavaScriptFile(expression) && + (expression.kind === 181) && + (expression.operatorToken.kind === 56) && + (expression.left.kind === 166) && + (expression.left.expression.kind === 69) && + ((expression.left.expression).text === "module") && + (expression.left.name.text === "exports"); + } + ts.isModuleExportsAssignment = isModuleExportsAssignment; function getExternalModuleName(node) { - if (node.kind === 220) { + if (node.kind === 222) { return node.moduleSpecifier; } - if (node.kind === 219) { + if (node.kind === 221) { var reference = node.moduleReference; - if (reference.kind === 230) { + if (reference.kind === 232) { return reference.expression; } } - if (node.kind === 226) { + if (node.kind === 228) { return node.moduleSpecifier; } } @@ -4276,13 +4343,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 136: + case 138: + case 143: + case 142: + case 246: + case 245: case 141: case 140: - case 244: - case 243: - case 139: - case 138: return node.questionToken !== undefined; } } @@ -4290,9 +4357,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 259 && + return node.kind === 261 && node.parameters.length > 0 && - node.parameters[0].type.kind === 261; + node.parameters[0].type.kind === 263; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -4306,24 +4373,24 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 267); + return getJSDocTag(node, 269); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 266); + return getJSDocTag(node, 268); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 268); + return getJSDocTag(node, 270); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 67) { + if (parameter.name && parameter.name.kind === 69) { var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 265) { + if (t.kind === 267) { var parameterTag = t; var name_7 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_7.text === parameterName) { @@ -4342,12 +4409,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32) { - if (node.type && node.type.kind === 260) { + if (node.type && node.type.kind === 262) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 260; + return paramTag.typeExpression.type.kind === 262; } } return node.dotDotDotToken !== undefined; @@ -4368,7 +4435,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 160 || node.kind === 159); + return !!node && (node.kind === 162 || node.kind === 161); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -4383,34 +4450,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 172: - case 161: - case 212: - case 184: - case 142: + case 174: + case 163: + case 214: + case 186: + case 144: + case 217: + case 247: + case 230: + case 213: + case 173: + case 145: + case 223: + case 221: + case 226: case 215: - case 245: - case 228: - case 211: - case 171: case 143: - case 221: - case 219: + case 142: + case 218: case 224: - case 213: + case 138: + case 245: case 141: case 140: + case 146: + case 246: case 216: - case 222: - case 136: - case 243: - case 139: - case 138: - case 144: - case 244: - case 214: - case 135: - case 209: + case 137: + case 211: return true; } return false; @@ -4418,25 +4485,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 201: - case 200: - case 208: + case 203: + case 202: + case 210: + case 197: case 195: + case 194: + case 200: + case 201: + case 199: + case 196: + case 207: + case 204: + case 206: + case 98: + case 209: case 193: - case 192: case 198: - case 199: - case 197: - case 194: case 205: - case 202: - case 204: - case 96: - case 207: - case 191: - case 196: - case 203: - case 225: + case 227: return true; default: return false; @@ -4445,13 +4512,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 142: - case 139: + case 144: case 141: case 143: - case 144: - case 140: - case 147: + case 145: + case 146: + case 142: + case 149: return true; default: return false; @@ -4459,11 +4526,11 @@ var ts; } ts.isClassElement = isClassElement; function isDeclarationName(name) { - if (name.kind !== 67 && name.kind !== 9 && name.kind !== 8) { + if (name.kind !== 69 && name.kind !== 9 && name.kind !== 8) { return false; } var parent = name.parent; - if (parent.kind === 224 || parent.kind === 228) { + if (parent.kind === 226 || parent.kind === 230) { if (parent.propertyName) { return true; } @@ -4477,54 +4544,54 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 139: - case 138: case 141: case 140: case 143: - case 144: + case 142: + case 145: + case 146: + case 247: case 245: - case 243: - case 164: + case 166: return parent.name === node; - case 133: + case 135: if (parent.right === node) { - while (parent.kind === 133) { + while (parent.kind === 135) { parent = parent.parent; } - return parent.kind === 152; + return parent.kind === 154; } return false; - case 161: - case 224: + case 163: + case 226: return parent.propertyName === node; - case 228: + case 230: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 219 || - node.kind === 221 && !!node.name || - node.kind === 222 || + return node.kind === 221 || + node.kind === 223 && !!node.name || node.kind === 224 || - node.kind === 228 || - node.kind === 225 && node.expression.kind === 67; + node.kind === 226 || + node.kind === 230 || + node.kind === 227 && node.expression.kind === 69; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 81); + var heritageClause = getHeritageClause(node.heritageClauses, 83); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 104); + var heritageClause = getHeritageClause(node.heritageClauses, 106); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 81); + var heritageClause = getHeritageClause(node.heritageClauses, 83); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -4593,7 +4660,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 68 <= token && token <= 132; + return 70 <= token && token <= 134; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -4606,19 +4673,19 @@ var ts; ts.isAsyncFunctionLike = isAsyncFunctionLike; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 134 && + declaration.name.kind === 136 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 164 && isESSymbolIdentifier(node.expression); + return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 67 || name.kind === 9 || name.kind === 8) { + if (name.kind === 69 || name.kind === 9 || name.kind === 8) { return name.text; } - if (name.kind === 134) { + if (name.kind === 136) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4633,21 +4700,21 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 67 && node.text === "Symbol"; + return node.kind === 69 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 113: - case 116: - case 72: - case 120: - case 75: - case 80: + case 115: + case 118: + case 74: + case 122: + case 77: + case 82: + case 112: case 110: - case 108: - case 109: case 111: + case 113: return true; } return false; @@ -4655,28 +4722,28 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 136; + return root.kind === 138; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 161) { + while (node.kind === 163) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 216 || n.kind === 246; + return isFunctionLike(n) || n.kind === 218 || n.kind === 248; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function cloneEntityName(node) { - if (node.kind === 67) { - var clone_1 = createSynthesizedNode(67); + if (node.kind === 69) { + var clone_1 = createSynthesizedNode(69); clone_1.text = node.text; return clone_1; } else { - var clone_2 = createSynthesizedNode(133); + var clone_2 = createSynthesizedNode(135); clone_2.left = cloneEntityName(node.left); clone_2.left.parent = clone_2; clone_2.right = cloneEntityName(node.right); @@ -4919,7 +4986,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 142 && nodeIsPresent(member.body)) { + if (member.kind === 144 && nodeIsPresent(member.body)) { return member; } }); @@ -4946,10 +5013,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 143) { + if (accessor.kind === 145) { getAccessor = accessor; } - else if (accessor.kind === 144) { + else if (accessor.kind === 146) { setAccessor = accessor; } else { @@ -4958,7 +5025,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 143 || member.kind === 144) + if ((member.kind === 145 || member.kind === 146) && (member.flags & 128) === (accessor.flags & 128)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -4969,10 +5036,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 143 && !getAccessor) { + if (member.kind === 145 && !getAccessor) { getAccessor = member; } - if (member.kind === 144 && !setAccessor) { + if (member.kind === 146 && !setAccessor) { setAccessor = member; } } @@ -5078,16 +5145,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 111: return 128; - case 110: return 16; - case 109: return 64; - case 108: return 32; - case 113: return 256; - case 80: return 1; - case 120: return 2; - case 72: return 32768; - case 75: return 1024; - case 116: return 512; + case 113: return 128; + case 112: return 16; + case 111: return 64; + case 110: return 32; + case 115: return 256; + case 82: return 1; + case 122: return 2; + case 74: return 32768; + case 77: return 1024; + case 118: return 512; } return 0; } @@ -5095,29 +5162,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 164: - case 165: - case 167: case 166: - case 231: - case 232: + case 167: + case 169: case 168: - case 162: + case 233: + case 234: case 170: - case 163: - case 184: - case 171: - case 67: + case 164: + case 172: + case 165: + case 186: + case 173: + case 69: case 10: case 8: case 9: case 11: - case 181: - case 82: - case 91: - case 95: - case 97: + case 183: + case 84: case 93: + case 97: + case 99: + case 95: return true; } } @@ -5125,12 +5192,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 55 && token <= 66; + return token >= 56 && token <= 68; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 186 && - node.parent.token === 81 && + return node.kind === 188 && + node.parent.token === 83 && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -5139,10 +5206,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 67) { + if (node.kind === 69) { return true; } - else if (node.kind === 164) { + else if (isPropertyAccessExpression(node)) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -5150,16 +5217,16 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 133 && node.parent.right === node) || - (node.parent.kind === 164 && node.parent.name === node); + return (node.parent.kind === 135 && node.parent.right === node) || + (node.parent.kind === 166 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 163) { + if (kind === 165) { return expression.properties.length === 0; } - if (kind === 162) { + if (kind === 164) { return expression.elements.length === 0; } return false; @@ -5169,12 +5236,12 @@ var ts; return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function isJavaScript(fileName) { - return ts.fileExtensionIs(fileName, ".js"); + function hasJavaScriptFileExtension(fileName) { + return ts.fileExtensionIs(fileName, ".js") || ts.fileExtensionIs(fileName, ".jsx"); } - ts.isJavaScript = isJavaScript; + ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; function isTsx(fileName) { - return ts.fileExtensionIs(fileName, ".tsx"); + return ts.fileExtensionIs(fileName, ".tsx") || ts.fileExtensionIs(fileName, ".jsx"); } ts.isTsx = isTsx; function getExpandedCharCodes(input) { @@ -5368,9 +5435,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 135) { + if (d && d.kind === 137) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 215) { return current; } } @@ -5380,7 +5447,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var nodeConstructors = new Array(270); + var nodeConstructors = new Array(272); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -5418,20 +5485,26 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 133: + case 135: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 135: + case 137: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 136: - case 139: + case 246: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.equalsToken) || + visitNode(cbNode, node.objectAssignmentInitializer); case 138: - case 243: - case 244: - case 209: - case 161: + case 141: + case 140: + case 245: + case 211: + case 163: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -5440,24 +5513,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 150: - case 151: - case 145: - case 146: + case 152: + case 153: case 147: + case 148: + case 149: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 141: - case 140: - case 142: case 143: + case 142: case 144: - case 171: - case 211: - case 172: + case 145: + case 146: + case 173: + case 213: + case 174: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -5468,290 +5541,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 149: + case 151: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 148: + case 150: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 152: - return visitNode(cbNode, node.exprName); - case 153: - return visitNodes(cbNodes, node.members); case 154: - return visitNode(cbNode, node.elementType); + return visitNode(cbNode, node.exprName); case 155: - return visitNodes(cbNodes, node.elementTypes); + return visitNodes(cbNodes, node.members); case 156: + return visitNode(cbNode, node.elementType); case 157: - return visitNodes(cbNodes, node.types); + return visitNodes(cbNodes, node.elementTypes); case 158: - return visitNode(cbNode, node.type); case 159: + return visitNodes(cbNodes, node.types); case 160: - return visitNodes(cbNodes, node.elements); + return visitNode(cbNode, node.type); + case 161: case 162: return visitNodes(cbNodes, node.elements); - case 163: - return visitNodes(cbNodes, node.properties); case 164: + return visitNodes(cbNodes, node.elements); + case 165: + return visitNodes(cbNodes, node.properties); + case 166: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 165: + case 167: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 166: - case 167: + case 168: + case 169: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 168: + case 170: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 169: + case 171: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 170: - return visitNode(cbNode, node.expression); - case 173: - return visitNode(cbNode, node.expression); - case 174: + case 172: return visitNode(cbNode, node.expression); case 175: return visitNode(cbNode, node.expression); + case 176: + return visitNode(cbNode, node.expression); case 177: + return visitNode(cbNode, node.expression); + case 179: return visitNode(cbNode, node.operand); - case 182: + case 184: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 176: - return visitNode(cbNode, node.expression); case 178: + return visitNode(cbNode, node.expression); + case 180: return visitNode(cbNode, node.operand); - case 179: + case 181: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 187: + case 189: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 180: + case 182: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 183: + case 185: return visitNode(cbNode, node.expression); - case 190: - case 217: + case 192: + case 219: return visitNodes(cbNodes, node.statements); - case 246: + case 248: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 191: + case 193: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 210: + case 212: return visitNodes(cbNodes, node.declarations); - case 193: + case 195: return visitNode(cbNode, node.expression); - case 194: + case 196: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 195: + case 197: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 196: + case 198: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 197: + case 199: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 198: + case 200: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 199: + case 201: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 200: - case 201: - return visitNode(cbNode, node.label); case 202: - return visitNode(cbNode, node.expression); case 203: + return visitNode(cbNode, node.label); + case 204: + return visitNode(cbNode, node.expression); + case 205: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 204: + case 206: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 218: + case 220: return visitNodes(cbNodes, node.clauses); - case 239: + case 241: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 240: + case 242: return visitNodes(cbNodes, node.statements); - case 205: + case 207: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 206: + case 208: return visitNode(cbNode, node.expression); - case 207: + case 209: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 242: + case 244: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 137: + case 139: return visitNode(cbNode, node.expression); - case 212: - case 184: + case 214: + case 186: 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 213: + case 215: 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 214: + case 216: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 215: + case 217: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 245: + case 247: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 216: + case 218: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 219: + case 221: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 220: + case 222: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 221: + case 223: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 222: + case 224: return visitNode(cbNode, node.name); - case 223: - case 227: + case 225: + case 229: return visitNodes(cbNodes, node.elements); - case 226: + case 228: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 224: - case 228: + case 226: + case 230: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 225: + case 227: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 181: + case 183: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 188: + case 190: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 134: + case 136: return visitNode(cbNode, node.expression); - case 241: + case 243: return visitNodes(cbNodes, node.types); - case 186: + case 188: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 230: + case 232: return visitNode(cbNode, node.expression); - case 229: - return visitNodes(cbNodes, node.decorators); case 231: + return visitNodes(cbNodes, node.decorators); + case 233: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 232: - case 233: + case 234: + case 235: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 236: + case 238: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 237: + case 239: return visitNode(cbNode, node.expression); - case 238: + case 240: return visitNode(cbNode, node.expression); - case 235: + case 237: return visitNode(cbNode, node.tagName); - case 247: + case 249: return visitNode(cbNode, node.type); - case 251: + case 253: return visitNodes(cbNodes, node.types); - case 252: + case 254: return visitNodes(cbNodes, node.types); - case 250: + case 252: return visitNode(cbNode, node.elementType); - case 254: - return visitNode(cbNode, node.type); - case 253: + case 256: return visitNode(cbNode, node.type); case 255: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.type); case 257: + return visitNodes(cbNodes, node.members); + case 259: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 258: + case 260: return visitNode(cbNode, node.type); - case 259: + case 261: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 260: + case 262: return visitNode(cbNode, node.type); - case 261: + case 263: return visitNode(cbNode, node.type); - case 262: + case 264: return visitNode(cbNode, node.type); - case 256: + case 258: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 263: - return visitNodes(cbNodes, node.tags); case 265: + return visitNodes(cbNodes, node.tags); + case 267: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 266: + case 268: return visitNode(cbNode, node.typeExpression); - case 267: + case 269: return visitNode(cbNode, node.typeExpression); - case 268: + case 270: return visitNodes(cbNodes, node.typeParameters); } } @@ -5792,13 +5865,14 @@ var ts; var contextFlags; var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes) { - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); + var isJavaScriptFile = ts.hasJavaScriptFileExtension(fileName) || _sourceText.lastIndexOf("// @language=javascript", 0) === 0; + initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor); var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); clearState(); return result; } Parser.parseSourceFile = parseSourceFile; - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor) { + function initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor) { sourceText = _sourceText; syntaxCursor = _syntaxCursor; parseDiagnostics = []; @@ -5806,7 +5880,7 @@ var ts; identifiers = {}; identifierCount = 0; nodeCount = 0; - contextFlags = ts.isJavaScript(fileName) ? 32 : 0; + contextFlags = isJavaScriptFile ? 32 : 0; parseErrorBeforeNextFinishedNode = false; scanner.setText(sourceText); scanner.setOnError(scanError); @@ -5824,6 +5898,9 @@ var ts; } function parseSourceFileWorker(fileName, languageVersion, setParentNodes) { sourceFile = createSourceFile(fileName, languageVersion); + if (contextFlags & 32) { + sourceFile.parserContextFlags = 32; + } token = nextToken(); processReferenceComments(sourceFile); sourceFile.statements = parseList(0, parseStatement); @@ -5837,7 +5914,7 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } - if (ts.isJavaScript(fileName)) { + if (ts.isSourceFileJavaScript(sourceFile)) { addJSDocComments(); } return sourceFile; @@ -5847,9 +5924,9 @@ var ts; return; function visit(node) { switch (node.kind) { - case 191: - case 211: - case 136: + case 193: + case 213: + case 138: addJSDocComment(node); } forEachChild(node, visit); @@ -5883,7 +5960,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(246, 0); + var sourceFile = createNode(248, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -6042,16 +6119,16 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token === 67) { + if (token === 69) { return true; } - if (token === 112 && inYieldContext()) { + if (token === 114 && inYieldContext()) { return false; } - if (token === 117 && inAwaitContext()) { + if (token === 119 && inAwaitContext()) { return false; } - return token > 103; + return token > 105; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -6147,15 +6224,15 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(67); - if (token !== 67) { + var node = createNode(69); + if (token !== 69) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(67, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(69, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -6187,7 +6264,7 @@ var ts; return token === 9 || token === 8 || ts.tokenIsIdentifierOrKeyword(token); } function parseComputedPropertyName() { - var node = createNode(134); + var node = createNode(136); parseExpected(19); node.expression = allowInAnd(parseExpression); parseExpected(20); @@ -6197,20 +6274,27 @@ var ts; return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 72) { - return nextToken() === 79; + if (token === 74) { + return nextToken() === 81; } - if (token === 80) { + if (token === 82) { nextToken(); - if (token === 75) { + if (token === 77) { return lookAhead(nextTokenIsClassOrFunction); } return token !== 37 && token !== 15 && canFollowModifier(); } - if (token === 75) { + if (token === 77) { return nextTokenIsClassOrFunction(); } + if (token === 113) { + nextToken(); + return canFollowModifier(); + } nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return false; + } return canFollowModifier(); } function parseAnyContextualModifier() { @@ -6224,7 +6308,7 @@ var ts; } function nextTokenIsClassOrFunction() { nextToken(); - return token === 71 || token === 85; + return token === 73 || token === 87; } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -6237,7 +6321,7 @@ var ts; case 3: return !(token === 23 && inErrorRecovery) && isStartOfStatement(); case 2: - return token === 69 || token === 75; + return token === 71 || token === 77; case 4: return isStartOfTypeMember(); case 5: @@ -6293,7 +6377,7 @@ var ts; ts.Debug.assert(token === 15); if (nextToken() === 16) { var next = nextToken(); - return next === 24 || next === 15 || next === 81 || next === 104; + return next === 24 || next === 15 || next === 83 || next === 106; } return true; } @@ -6306,8 +6390,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 104 || - token === 81) { + if (token === 106 || + token === 83) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -6331,13 +6415,13 @@ var ts; case 21: return token === 16; case 3: - return token === 16 || token === 69 || token === 75; + return token === 16 || token === 71 || token === 77; case 7: - return token === 15 || token === 81 || token === 104; + return token === 15 || token === 83 || token === 106; case 8: return isVariableDeclaratorListTerminator(); case 17: - return token === 27 || token === 17 || token === 15 || token === 81 || token === 104; + return token === 27 || token === 17 || token === 15 || token === 83 || token === 106; case 11: return token === 18 || token === 23; case 15: @@ -6351,11 +6435,11 @@ var ts; case 20: return token === 15 || token === 16; case 13: - return token === 27 || token === 38; + return token === 27 || token === 39; case 14: return token === 25 && lookAhead(nextTokenIsSlash); case 22: - return token === 18 || token === 53 || token === 16; + return token === 18 || token === 54 || token === 16; case 23: return token === 27 || token === 16; case 25: @@ -6476,17 +6560,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 142: - case 147: - case 143: case 144: - case 139: - case 189: - return true; + case 149: + case 145: + case 146: case 141: + case 191: + return true; + case 143: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 67 && - methodDeclaration.name.originalKeywordKind === 119; + var nameIsConstructor = methodDeclaration.name.kind === 69 && + methodDeclaration.name.originalKeywordKind === 121; return !nameIsConstructor; } } @@ -6495,8 +6579,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 239: - case 240: + case 241: + case 242: return true; } } @@ -6505,65 +6589,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 211: - case 191: - case 190: - case 194: + case 213: case 193: + case 192: + case 196: + case 195: + case 208: + case 204: case 206: + case 203: case 202: - case 204: - case 201: case 200: - case 198: + case 201: case 199: - case 197: - case 196: - case 203: - case 192: - case 207: + case 198: case 205: - case 195: - case 208: - case 220: - case 219: - case 226: - case 225: - case 216: - case 212: - case 213: - case 215: + case 194: + case 209: + case 207: + case 197: + case 210: + case 222: + case 221: + case 228: + case 227: + case 218: case 214: + case 215: + case 217: + case 216: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 245; + return node.kind === 247; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 146: + case 148: + case 142: + case 149: case 140: case 147: - case 138: - case 145: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 209) { + if (node.kind !== 211) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 136) { + if (node.kind !== 138) { return false; } var parameter = node; @@ -6663,7 +6747,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(21)) { - var node = createNode(133, entity.pos); + var node = createNode(135, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -6674,13 +6758,13 @@ var ts; if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(67, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(69, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(181); + var template = createNode(183); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); var templateSpans = []; @@ -6693,7 +6777,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(188); + var span = createNode(190); span.expression = allowInAnd(parseExpression); var literal; if (token === 16) { @@ -6728,14 +6812,14 @@ var ts; } function parseTypeReferenceOrTypePredicate() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 67 && token === 122 && !scanner.hasPrecedingLineBreak()) { + if (typeName.kind === 69 && token === 124 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(148, typeName.pos); + var node_1 = createNode(150, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(149, typeName.pos); + var node = createNode(151, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 25) { node.typeArguments = parseBracketedList(18, parseType, 25, 27); @@ -6743,15 +6827,15 @@ var ts; return finishNode(node); } function parseTypeQuery() { - var node = createNode(152); - parseExpected(99); + var node = createNode(154); + parseExpected(101); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(135); + var node = createNode(137); node.name = parseIdentifier(); - if (parseOptional(81)) { + if (parseOptional(83)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -6767,7 +6851,7 @@ var ts; } } function parseParameterType() { - if (parseOptional(53)) { + if (parseOptional(54)) { return token === 9 ? parseLiteralNode(true) : parseType(); @@ -6775,7 +6859,7 @@ var ts; return undefined; } function isStartOfParameter() { - return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 54; + return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 55; } function setModifiers(node, modifiers) { if (modifiers) { @@ -6784,7 +6868,7 @@ var ts; } } function parseParameter() { - var node = createNode(136); + var node = createNode(138); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(22); @@ -6792,7 +6876,7 @@ var ts; if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { nextToken(); } - node.questionToken = parseOptionalToken(52); + node.questionToken = parseOptionalToken(53); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); return finishNode(node); @@ -6839,10 +6923,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 146) { - parseExpected(90); + if (kind === 148) { + parseExpected(92); } - fillSignature(53, false, false, false, node); + fillSignature(54, false, false, false, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -6869,17 +6953,17 @@ var ts; else { nextToken(); } - if (token === 53 || token === 24) { + if (token === 54 || token === 24) { return true; } - if (token !== 52) { + if (token !== 53) { return false; } nextToken(); - return token === 53 || token === 24 || token === 20; + return token === 54 || token === 24 || token === 20; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(147, fullStart); + var node = createNode(149, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(16, parseParameter, 19, 20); @@ -6890,17 +6974,17 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (token === 17 || token === 25) { - var method = createNode(140, fullStart); + var method = createNode(142, fullStart); method.name = name; method.questionToken = questionToken; - fillSignature(53, false, false, false, method); + fillSignature(54, false, false, false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(138, fullStart); + var property = createNode(140, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -6934,22 +7018,22 @@ var ts; nextToken(); return token === 17 || token === 25 || - token === 52 || token === 53 || + token === 54 || canParseSemicolon(); } function parseTypeMember() { switch (token) { case 17: case 25: - return parseSignatureMember(145); + return parseSignatureMember(147); case 19: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); - case 90: + case 92: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(146); + return parseSignatureMember(148); } case 9: case 8: @@ -6979,7 +7063,7 @@ var ts; return token === 17 || token === 25; } function parseTypeLiteral() { - var node = createNode(153); + var node = createNode(155); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -6995,12 +7079,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(155); + var node = createNode(157); node.elementTypes = parseBracketedList(19, parseType, 19, 20); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(158); + var node = createNode(160); parseExpected(17); node.type = parseType(); parseExpected(18); @@ -7008,8 +7092,8 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 151) { - parseExpected(90); + if (kind === 153) { + parseExpected(92); } fillSignature(34, false, false, false, node); return finishNode(node); @@ -7020,16 +7104,17 @@ var ts; } function parseNonArrayType() { switch (token) { - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: + case 120: + case 131: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 101: + case 103: + case 97: return parseTokenNode(); - case 99: + case 101: return parseTypeQuery(); case 15: return parseTypeLiteral(); @@ -7043,17 +7128,18 @@ var ts; } function isStartOfType() { switch (token) { - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: + case 120: + case 131: + case 103: + case 97: case 101: - case 99: case 15: case 19: case 25: - case 90: + case 92: return true; case 17: return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -7069,7 +7155,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { parseExpected(20); - var node = createNode(154, type.pos); + var node = createNode(156, type.pos); node.elementType = type; type = finishNode(node); } @@ -7091,10 +7177,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(157, parseArrayTypeOrHigher, 45); + return parseUnionOrIntersectionType(159, parseArrayTypeOrHigher, 46); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(156, parseIntersectionTypeOrHigher, 46); + return parseUnionOrIntersectionType(158, parseIntersectionTypeOrHigher, 47); } function isStartOfFunctionType() { if (token === 25) { @@ -7109,8 +7195,8 @@ var ts; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 53 || token === 24 || - token === 52 || token === 55 || + if (token === 54 || token === 24 || + token === 53 || token === 56 || isIdentifier() || ts.isModifier(token)) { return true; } @@ -7128,23 +7214,23 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(150); + return parseFunctionOrConstructorType(152); } - if (token === 90) { - return parseFunctionOrConstructorType(151); + if (token === 92) { + return parseFunctionOrConstructorType(153); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(53) ? parseType() : undefined; + return parseOptional(54) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token) { + case 97: case 95: case 93: - case 91: - case 97: - case 82: + case 99: + case 84: case 8: case 9: case 11: @@ -7152,12 +7238,12 @@ var ts; case 17: case 19: case 15: - case 85: - case 71: - case 90: - case 38: - case 59: - case 67: + case 87: + case 73: + case 92: + case 39: + case 61: + case 69: return true; default: return isIdentifier(); @@ -7170,16 +7256,16 @@ var ts; switch (token) { case 35: case 36: + case 50: case 49: - case 48: - case 76: - case 99: + case 78: case 101: - case 40: + case 103: case 41: + case 42: case 25: - case 117: - case 112: + case 119: + case 114: return true; default: if (isBinaryOperator()) { @@ -7190,9 +7276,9 @@ var ts; } function isStartOfExpressionStatement() { return token !== 15 && - token !== 85 && - token !== 71 && - token !== 54 && + token !== 87 && + token !== 73 && + token !== 55 && isStartOfExpression(); } function allowInAndParseExpression() { @@ -7214,12 +7300,12 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 55) { + if (token !== 56) { if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15) || !isStartOfExpression()) { return undefined; } } - parseExpected(55); + parseExpected(56); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -7231,7 +7317,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 67 && token === 34) { + if (expr.kind === 69 && token === 34) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -7240,7 +7326,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 112) { + if (token === 114) { if (inYieldContext()) { return true; } @@ -7253,7 +7339,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(182); + var node = createNode(184); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 37 || isStartOfExpression())) { @@ -7267,8 +7353,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(172, identifier.pos); - var parameter = createNode(136, identifier.pos); + var node = createNode(174, identifier.pos); + var parameter = createNode(138, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -7298,7 +7384,7 @@ var ts; return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { - if (token === 17 || token === 25 || token === 116) { + if (token === 17 || token === 25 || token === 118) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } if (token === 34) { @@ -7307,7 +7393,7 @@ var ts; return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 116) { + if (token === 118) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; @@ -7323,7 +7409,7 @@ var ts; var third = nextToken(); switch (third) { case 34: - case 53: + case 54: case 15: return 1; default: @@ -7339,7 +7425,7 @@ var ts; if (!isIdentifier()) { return 0; } - if (nextToken() === 53) { + if (nextToken() === 54) { return 1; } return 2; @@ -7352,10 +7438,10 @@ var ts; if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 81) { + if (third === 83) { var fourth = nextToken(); switch (fourth) { - case 55: + case 56: case 27: return false; default: @@ -7379,10 +7465,10 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(172); + var node = createNode(174); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512); - fillSignature(53, false, isAsync, !allowAmbiguity, node); + fillSignature(54, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } @@ -7396,8 +7482,8 @@ var ts; return parseFunctionBlock(false, isAsync, false); } if (token !== 23 && - token !== 85 && - token !== 71 && + token !== 87 && + token !== 73 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(false, isAsync, true); @@ -7407,15 +7493,15 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (!questionToken) { return leftOperand; } - var node = createNode(180, leftOperand.pos); + var node = createNode(182, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(53, false, ts.Diagnostics._0_expected, ts.tokenToString(53)); + node.colonToken = parseExpectedToken(54, false, ts.Diagnostics._0_expected, ts.tokenToString(54)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -7424,19 +7510,22 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 88 || t === 132; + return t === 90 || t === 134; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); var newPrecedence = getBinaryOperatorPrecedence(); - if (newPrecedence <= precedence) { + var consumeCurrentOperator = token === 38 ? + newPrecedence >= precedence : + newPrecedence > precedence; + if (!consumeCurrentOperator) { break; } - if (token === 88 && inDisallowInContext()) { + if (token === 90 && inDisallowInContext()) { break; } - if (token === 114) { + if (token === 116) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -7452,22 +7541,22 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 88) { + if (inDisallowInContext() && token === 90) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 51: + case 52: return 1; - case 50: + case 51: return 2; - case 46: - return 3; case 47: + return 3; + case 48: return 4; - case 45: + case 46: return 5; case 30: case 31: @@ -7478,64 +7567,66 @@ var ts; case 27: case 28: case 29: - case 89: - case 88: - case 114: + case 91: + case 90: + case 116: return 7; - case 42: case 43: case 44: + case 45: return 8; case 35: case 36: return 9; case 37: - case 38: case 39: + case 40: return 10; + case 38: + return 11; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(179, left.pos); + var node = createNode(181, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(187, left.pos); + var node = createNode(189, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(177); + var node = createNode(179); node.operator = token; nextToken(); - node.operand = parseUnaryExpressionOrHigher(); + node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(173); + var node = createNode(175); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(174); + var node = createNode(176); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(175); + var node = createNode(177); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token === 117) { + if (token === 119) { if (inAwaitContext()) { return true; } @@ -7544,45 +7635,87 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(176); + var node = createNode(178); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseUnaryExpressionOrHigher() { if (isAwaitExpression()) { return parseAwaitExpression(); } + if (isIncrementExpression()) { + var incrementExpression = parseIncrementExpression(); + return token === 38 ? + parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : + incrementExpression; + } + var unaryOperator = token; + var simpleUnaryExpression = parseSimpleUnaryExpression(); + if (token === 38) { + var diagnostic; + var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); + if (simpleUnaryExpression.kind === 171) { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); + } + else { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, ts.tokenToString(unaryOperator)); + } + } + return simpleUnaryExpression; + } + function parseSimpleUnaryExpression() { switch (token) { case 35: case 36: + case 50: case 49: - case 48: - case 40: - case 41: return parsePrefixUnaryExpression(); - case 76: + case 78: return parseDeleteExpression(); - case 99: - return parseTypeOfExpression(); case 101: + return parseTypeOfExpression(); + case 103: return parseVoidExpression(); + case 25: + return parseTypeAssertion(); + default: + return parseIncrementExpression(); + } + } + function isIncrementExpression() { + switch (token) { + case 35: + case 36: + case 50: + case 49: + case 78: + case 101: + case 103: + return false; case 25: if (sourceFile.languageVariant !== 1) { - return parseTypeAssertion(); - } - if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(true); + return false; } default: - return parsePostfixExpressionOrHigher(); + return true; } } - function parsePostfixExpressionOrHigher() { + function parseIncrementExpression() { + if (token === 41 || token === 42) { + var node = createNode(179); + node.operator = token; + nextToken(); + node.operand = parseLeftHandSideExpressionOrHigher(); + return finishNode(node); + } + else if (sourceFile.languageVariant === 1 && token === 25 && lookAhead(nextTokenIsIdentifierOrKeyword)) { + return parseJsxElementOrSelfClosingElement(true); + } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 40 || token === 41) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(178, expression.pos); + if ((token === 41 || token === 42) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(180, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -7591,7 +7724,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token === 93 + var expression = token === 95 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -7605,7 +7738,7 @@ var ts; if (token === 17 || token === 21 || token === 19) { return expression; } - var node = createNode(164, expression.pos); + var node = createNode(166, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -7613,26 +7746,26 @@ var ts; } function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); - if (opening.kind === 233) { - var node = createNode(231, opening.pos); + if (opening.kind === 235) { + var node = createNode(233, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 232); + ts.Debug.assert(opening.kind === 234); return opening; } } function parseJsxText() { - var node = createNode(234, scanner.getStartPos()); + var node = createNode(236, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 234: + case 236: return parseJsxText(); case 15: return parseJsxExpression(false); @@ -7668,11 +7801,11 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token === 27) { - node = createNode(233, fullStart); + node = createNode(235, fullStart); scanJsxText(); } else { - parseExpected(38); + parseExpected(39); if (inExpressionContext) { parseExpected(27); } @@ -7680,7 +7813,7 @@ var ts; parseExpected(27, undefined, false); scanJsxText(); } - node = createNode(232, fullStart); + node = createNode(234, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -7691,7 +7824,7 @@ var ts; var elementName = parseIdentifierName(); while (parseOptional(21)) { scanJsxIdentifier(); - var node = createNode(133, elementName.pos); + var node = createNode(135, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); @@ -7699,7 +7832,7 @@ var ts; return elementName; } function parseJsxExpression(inExpressionContext) { - var node = createNode(238); + var node = createNode(240); parseExpected(15); if (token !== 16) { node.expression = parseExpression(); @@ -7718,9 +7851,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(236); + var node = createNode(238); node.name = parseIdentifierName(); - if (parseOptional(55)) { + if (parseOptional(56)) { switch (token) { case 9: node.initializer = parseLiteralNode(); @@ -7733,7 +7866,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(237); + var node = createNode(239); parseExpected(15); parseExpected(22); node.expression = parseExpression(); @@ -7741,7 +7874,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(235); + var node = createNode(237); parseExpected(26); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -7754,18 +7887,18 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(169); + var node = createNode(171); parseExpected(25); node.type = parseType(); parseExpected(27); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { var dotToken = parseOptionalToken(21); if (dotToken) { - var propertyAccess = createNode(164, expression.pos); + var propertyAccess = createNode(166, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -7773,7 +7906,7 @@ var ts; continue; } if (!inDecoratorContext() && parseOptional(19)) { - var indexedAccess = createNode(165, expression.pos); + var indexedAccess = createNode(167, expression.pos); indexedAccess.expression = expression; if (token !== 20) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -7787,7 +7920,7 @@ var ts; continue; } if (token === 11 || token === 12) { - var tagExpression = createNode(168, expression.pos); + var tagExpression = createNode(170, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 11 ? parseLiteralNode() @@ -7806,7 +7939,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(166, expression.pos); + var callExpr = createNode(168, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -7814,7 +7947,7 @@ var ts; continue; } else if (token === 17) { - var callExpr = createNode(166, expression.pos); + var callExpr = createNode(168, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -7847,18 +7980,18 @@ var ts; case 21: case 18: case 20: - case 53: + case 54: case 23: - case 52: + case 53: case 30: case 32: case 31: case 33: - case 50: case 51: - case 47: - case 45: + case 52: + case 48: case 46: + case 47: case 16: case 1: return true; @@ -7874,11 +8007,11 @@ var ts; case 9: case 11: return parseLiteralNode(); + case 97: case 95: case 93: - case 91: - case 97: - case 82: + case 99: + case 84: return parseTokenNode(); case 17: return parseParenthesizedExpression(); @@ -7886,19 +8019,19 @@ var ts; return parseArrayLiteralExpression(); case 15: return parseObjectLiteralExpression(); - case 116: + case 118: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 71: + case 73: return parseClassExpression(); - case 85: + case 87: return parseFunctionExpression(); - case 90: + case 92: return parseNewExpression(); - case 38: - case 59: + case 39: + case 61: if (reScanSlashToken() === 10) { return parseLiteralNode(); } @@ -7909,28 +8042,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(170); + var node = createNode(172); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); return finishNode(node); } function parseSpreadElement() { - var node = createNode(183); + var node = createNode(185); parseExpected(22); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 22 ? parseSpreadElement() : - token === 24 ? createNode(185) : + token === 24 ? createNode(187) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(162); + var node = createNode(164); parseExpected(19); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048; @@ -7939,11 +8072,11 @@ var ts; return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(121)) { - return parseAccessorDeclaration(143, fullStart, decorators, modifiers); + if (parseContextualModifier(123)) { + return parseAccessorDeclaration(145, fullStart, decorators, modifiers); } - else if (parseContextualModifier(127)) { - return parseAccessorDeclaration(144, fullStart, decorators, modifiers); + else if (parseContextualModifier(129)) { + return parseAccessorDeclaration(146, fullStart, decorators, modifiers); } return undefined; } @@ -7959,27 +8092,33 @@ var ts; var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - if ((token === 24 || token === 16) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(244, fullStart); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 || token === 16 || token === 56); + if (isShorthandPropertyAssignment) { + var shorthandDeclaration = createNode(246, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; + var equalsToken = parseOptionalToken(56); + if (equalsToken) { + shorthandDeclaration.equalsToken = equalsToken; + shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); + } return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(243, fullStart); + var propertyAssignment = createNode(245, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(53); + parseExpected(54); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(163); + var node = createNode(165); parseExpected(15); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048; @@ -7993,9 +8132,9 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(171); + var node = createNode(173); setModifiers(node, parseModifiers()); - parseExpected(85); + parseExpected(87); node.asteriskToken = parseOptionalToken(37); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); @@ -8004,7 +8143,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(53, isGenerator, isAsync, false, node); + fillSignature(54, isGenerator, isAsync, false, node); node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -8015,8 +8154,8 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(167); - parseExpected(90); + var node = createNode(169); + parseExpected(92); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token === 17) { @@ -8025,7 +8164,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(190); + var node = createNode(192); if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1, parseStatement); parseExpected(16); @@ -8053,25 +8192,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(192); + var node = createNode(194); parseExpected(23); return finishNode(node); } function parseIfStatement() { - var node = createNode(194); - parseExpected(86); + var node = createNode(196); + parseExpected(88); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(78) ? parseStatement() : undefined; + node.elseStatement = parseOptional(80) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(195); - parseExpected(77); + var node = createNode(197); + parseExpected(79); node.statement = parseStatement(); - parseExpected(102); + parseExpected(104); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); @@ -8079,8 +8218,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(196); - parseExpected(102); + var node = createNode(198); + parseExpected(104); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); @@ -8089,11 +8228,11 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(84); + parseExpected(86); parseExpected(17); var initializer = undefined; if (token !== 23) { - if (token === 100 || token === 106 || token === 72) { + if (token === 102 || token === 108 || token === 74) { initializer = parseVariableDeclarationList(true); } else { @@ -8101,22 +8240,22 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(88)) { - var forInStatement = createNode(198, pos); + if (parseOptional(90)) { + var forInStatement = createNode(200, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(18); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(132)) { - var forOfStatement = createNode(199, pos); + else if (parseOptional(134)) { + var forOfStatement = createNode(201, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(18); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(197, pos); + var forStatement = createNode(199, pos); forStatement.initializer = initializer; parseExpected(23); if (token !== 23 && token !== 18) { @@ -8134,7 +8273,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 201 ? 68 : 73); + parseExpected(kind === 203 ? 70 : 75); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -8142,8 +8281,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(202); - parseExpected(92); + var node = createNode(204); + parseExpected(94); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -8151,8 +8290,8 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(203); - parseExpected(103); + var node = createNode(205); + parseExpected(105); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); @@ -8160,30 +8299,30 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(239); - parseExpected(69); + var node = createNode(241); + parseExpected(71); node.expression = allowInAnd(parseExpression); - parseExpected(53); + parseExpected(54); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(240); - parseExpected(75); - parseExpected(53); + var node = createNode(242); + parseExpected(77); + parseExpected(54); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 69 ? parseCaseClause() : parseDefaultClause(); + return token === 71 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(204); - parseExpected(94); + var node = createNode(206); + parseExpected(96); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); - var caseBlock = createNode(218, scanner.getStartPos()); + var caseBlock = createNode(220, scanner.getStartPos()); parseExpected(15); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(16); @@ -8191,26 +8330,26 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(206); - parseExpected(96); + var node = createNode(208); + parseExpected(98); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(207); - parseExpected(98); + var node = createNode(209); + parseExpected(100); node.tryBlock = parseBlock(false); - node.catchClause = token === 70 ? parseCatchClause() : undefined; - if (!node.catchClause || token === 83) { - parseExpected(83); + node.catchClause = token === 72 ? parseCatchClause() : undefined; + if (!node.catchClause || token === 85) { + parseExpected(85); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(242); - parseExpected(70); + var result = createNode(244); + parseExpected(72); if (parseExpected(17)) { result.variableDeclaration = parseVariableDeclaration(); } @@ -8219,22 +8358,22 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(208); - parseExpected(74); + var node = createNode(210); + parseExpected(76); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 67 && parseOptional(53)) { - var labeledStatement = createNode(205, fullStart); + if (expression.kind === 69 && parseOptional(54)) { + var labeledStatement = createNode(207, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(193, fullStart); + var expressionStatement = createNode(195, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -8246,7 +8385,7 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 85 && !scanner.hasPrecedingLineBreak(); + return token === 87 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -8255,41 +8394,41 @@ var ts; function isDeclaration() { while (true) { switch (token) { - case 100: - case 106: - case 72: - case 85: - case 71: - case 79: + case 102: + case 108: + case 74: + case 87: + case 73: + case 81: return true; - case 105: - case 130: + case 107: + case 132: return nextTokenIsIdentifierOnSameLine(); - case 123: - case 124: + case 125: + case 126: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 116: - case 120: + case 115: + case 118: + case 122: + case 110: + case 111: + case 112: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 87: + case 89: nextToken(); return token === 9 || token === 37 || token === 15 || ts.tokenIsIdentifierOrKeyword(token); - case 80: + case 82: nextToken(); - if (token === 55 || token === 37 || - token === 15 || token === 75) { + if (token === 56 || token === 37 || + token === 15 || token === 77) { return true; } continue; - case 110: - case 108: - case 109: - case 111: case 113: nextToken(); continue; @@ -8303,44 +8442,44 @@ var ts; } function isStartOfStatement() { switch (token) { - case 54: + case 55: case 23: case 15: - case 100: - case 106: - case 85: - case 71: - case 79: - case 86: - case 77: case 102: - case 84: + case 108: + case 87: case 73: - case 68: - case 92: - case 103: + case 81: + case 88: + case 79: + case 104: + case 86: + case 75: + case 70: case 94: + case 105: case 96: case 98: - case 74: - case 70: - case 83: - return true; + case 100: + case 76: case 72: - case 80: - case 87: + case 85: + return true; + case 74: + case 82: + case 89: return isStartOfDeclaration(); - case 116: - case 120: - case 105: - case 123: - case 124: - case 130: + case 118: + case 122: + case 107: + case 125: + case 126: + case 132: return true; + case 112: case 110: - case 108: - case 109: case 111: + case 113: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -8359,60 +8498,60 @@ var ts; return parseEmptyStatement(); case 15: return parseBlock(false); - case 100: + case 102: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 106: + case 108: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 85: + case 87: return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 71: + case 73: return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); - case 86: + case 88: return parseIfStatement(); - case 77: + case 79: return parseDoStatement(); - case 102: + case 104: return parseWhileStatement(); - case 84: + case 86: return parseForOrForInOrForOfStatement(); - case 73: - return parseBreakOrContinueStatement(200); - case 68: - return parseBreakOrContinueStatement(201); - case 92: + case 75: + return parseBreakOrContinueStatement(202); + case 70: + return parseBreakOrContinueStatement(203); + case 94: return parseReturnStatement(); - case 103: + case 105: return parseWithStatement(); - case 94: - return parseSwitchStatement(); case 96: - return parseThrowStatement(); + return parseSwitchStatement(); case 98: - case 70: - case 83: + return parseThrowStatement(); + case 100: + case 72: + case 85: return parseTryStatement(); - case 74: + case 76: return parseDebuggerStatement(); - case 54: + case 55: return parseDeclaration(); - case 116: - case 105: - case 130: - case 123: - case 124: - case 120: - case 72: - case 79: - case 80: - case 87: - case 108: - case 109: + case 118: + case 107: + case 132: + case 125: + case 126: + case 122: + case 74: + case 81: + case 82: + case 89: case 110: - case 113: case 111: + case 112: + case 115: + case 113: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -8425,33 +8564,33 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 100: - case 106: - case 72: + case 102: + case 108: + case 74: return parseVariableStatement(fullStart, decorators, modifiers); - case 85: + case 87: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 71: + case 73: return parseClassDeclaration(fullStart, decorators, modifiers); - case 105: + case 107: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 130: + case 132: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 79: + case 81: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 123: - case 124: + case 125: + case 126: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 87: + case 89: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 80: + case 82: nextToken(); - return token === 75 || token === 55 ? + return token === 77 || token === 56 ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { - var node = createMissingNode(229, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(231, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -8472,23 +8611,23 @@ var ts; } function parseArrayBindingElement() { if (token === 24) { - return createNode(185); + return createNode(187); } - var node = createNode(161); + var node = createNode(163); node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(161); + var node = createNode(163); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 53) { + if (tokenIsIdentifier && token !== 54) { node.name = propertyName; } else { - parseExpected(53); + parseExpected(54); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -8496,14 +8635,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(159); + var node = createNode(161); parseExpected(15); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(16); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(160); + var node = createNode(162); parseExpected(19); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(20); @@ -8522,7 +8661,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(209); + var node = createNode(211); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -8531,21 +8670,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(210); + var node = createNode(212); switch (token) { - case 100: + case 102: break; - case 106: + case 108: node.flags |= 16384; break; - case 72: + case 74: node.flags |= 32768; break; default: ts.Debug.fail(); } nextToken(); - if (token === 132 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 134 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -8560,7 +8699,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 18; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(191, fullStart); + var node = createNode(193, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -8568,29 +8707,29 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(211, fullStart); + var node = createNode(213, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(85); + parseExpected(87); node.asteriskToken = parseOptionalToken(37); node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); - fillSignature(53, isGenerator, isAsync, false, node); + fillSignature(54, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(142, pos); + var node = createNode(144, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(119); - fillSignature(53, false, false, false, node); + parseExpected(121); + fillSignature(54, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(141, fullStart); + var method = createNode(143, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -8598,12 +8737,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512); - fillSignature(53, isGenerator, isAsync, false, method); + fillSignature(54, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(139, fullStart); + var property = createNode(141, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -8618,7 +8757,7 @@ var ts; function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { var asteriskToken = parseOptionalToken(37); var name = parsePropertyName(); - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } @@ -8634,16 +8773,16 @@ var ts; node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(53, false, false, false, node); + fillSignature(54, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { + case 112: case 110: - case 108: - case 109: case 111: + case 113: return true; default: return false; @@ -8651,7 +8790,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 54) { + if (token === 55) { return true; } while (ts.isModifier(token)) { @@ -8672,15 +8811,15 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 127 || idToken === 121) { + if (!ts.isKeyword(idToken) || idToken === 129 || idToken === 123) { return true; } switch (token) { case 17: case 25: + case 54: + case 56: case 53: - case 55: - case 52: return true; default: return canParseSemicolon(); @@ -8692,14 +8831,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(54)) { + if (!parseOptional(55)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(137, decoratorStart); + var decorator = createNode(139, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -8733,7 +8872,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 116) { + if (token === 118) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -8748,7 +8887,7 @@ var ts; } function parseClassElement() { if (token === 23) { - var result = createNode(189); + var result = createNode(191); nextToken(); return finishNode(result); } @@ -8759,7 +8898,7 @@ var ts; if (accessor) { return accessor; } - if (token === 119) { + if (token === 121) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -8773,23 +8912,23 @@ var ts; return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_8 = createMissingNode(67, true, ts.Diagnostics.Declaration_expected); + var name_8 = createMissingNode(69, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_8, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 184); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 186); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 214); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(71); - node.name = parseOptionalIdentifier(); + parseExpected(73); + node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(true); if (parseExpected(15)) { @@ -8801,6 +8940,14 @@ var ts; } return finishNode(node); } + function parseNameOfClassDeclarationOrExpression() { + return isIdentifier() && !isImplementsClause() + ? parseIdentifier() + : undefined; + } + function isImplementsClause() { + return token === 106 && lookAhead(nextTokenIsIdentifierOrKeyword); + } function parseHeritageClauses(isClassHeritageClause) { if (isHeritageClause()) { return parseList(20, parseHeritageClause); @@ -8811,8 +8958,8 @@ var ts; return parseList(20, parseHeritageClause); } function parseHeritageClause() { - if (token === 81 || token === 104) { - var node = createNode(241); + if (token === 83 || token === 106) { + var node = createNode(243); node.token = token; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -8821,7 +8968,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(186); + var node = createNode(188); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 25) { node.typeArguments = parseBracketedList(18, parseType, 25, 27); @@ -8829,16 +8976,16 @@ var ts; return finishNode(node); } function isHeritageClause() { - return token === 81 || token === 104; + return token === 83 || token === 106; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213, fullStart); + var node = createNode(215, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(105); + parseExpected(107); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(false); @@ -8846,28 +8993,28 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214, fullStart); + var node = createNode(216, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(130); + parseExpected(132); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(55); + parseExpected(56); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(245, scanner.getStartPos()); + var node = createNode(247, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); + var node = createNode(217, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(79); + parseExpected(81); node.name = parseIdentifier(); if (parseExpected(15)) { node.members = parseDelimitedList(6, parseEnumMember); @@ -8879,7 +9026,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(217, scanner.getStartPos()); + var node = createNode(219, scanner.getStartPos()); if (parseExpected(15)) { node.statements = parseList(1, parseStatement); parseExpected(16); @@ -8890,7 +9037,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(216, fullStart); + var node = createNode(218, fullStart); var namespaceFlag = flags & 131072; node.decorators = decorators; setModifiers(node, modifiers); @@ -8902,7 +9049,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216, fullStart); + var node = createNode(218, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -8911,11 +9058,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(124)) { + if (parseOptional(126)) { flags |= 131072; } else { - parseExpected(123); + parseExpected(125); if (token === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -8923,58 +9070,58 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 125 && + return token === 127 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 17; } function nextTokenIsSlash() { - return nextToken() === 38; + return nextToken() === 39; } function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 24 || - token === 131; + token === 133; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(87); + parseExpected(89); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 24 && token !== 131) { - var importEqualsDeclaration = createNode(219, fullStart); + if (token !== 24 && token !== 133) { + var importEqualsDeclaration = createNode(221, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(55); + parseExpected(56); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(220, fullStart); + var importDeclaration = createNode(222, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || token === 37 || token === 15) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(131); + parseExpected(133); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(221, fullStart); + var importClause = createNode(223, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(24)) { - importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(223); + importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(225); } return finishNode(importClause); } @@ -8984,8 +9131,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(230); - parseExpected(125); + var node = createNode(232); + parseExpected(127); parseExpected(17); node.expression = parseModuleSpecifier(); parseExpected(18); @@ -8999,22 +9146,22 @@ var ts; return result; } function parseNamespaceImport() { - var namespaceImport = createNode(222); + var namespaceImport = createNode(224); parseExpected(37); - parseExpected(114); + parseExpected(116); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 223 ? parseImportSpecifier : parseExportSpecifier, 15, 16); + node.elements = parseBracketedList(21, kind === 225 ? parseImportSpecifier : parseExportSpecifier, 15, 16); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(228); + return parseImportOrExportSpecifier(230); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(224); + return parseImportOrExportSpecifier(226); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -9022,9 +9169,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 114) { + if (token === 116) { node.propertyName = identifierName; - parseExpected(114); + parseExpected(116); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -9033,23 +9180,23 @@ var ts; else { node.name = identifierName; } - if (kind === 224 && checkIdentifierIsKeyword) { + if (kind === 226 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226, fullStart); + var node = createNode(228, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(37)) { - parseExpected(131); + parseExpected(133); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(227); - if (token === 131 || (token === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(131); + node.exportClause = parseNamedImportsOrExports(229); + if (token === 133 || (token === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(133); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -9057,14 +9204,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(227, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(55)) { + if (parseOptional(56)) { node.isExportEquals = true; } else { - parseExpected(75); + parseExpected(77); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -9127,10 +9274,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 219 && node.moduleReference.kind === 230 - || node.kind === 220 - || node.kind === 225 - || node.kind === 226 + || node.kind === 221 && node.moduleReference.kind === 232 + || node.kind === 222 + || node.kind === 227 + || node.kind === 228 ? node : undefined; }); @@ -9140,22 +9287,22 @@ var ts; function isJSDocType() { switch (token) { case 37: - case 52: + case 53: case 17: case 19: - case 48: + case 49: case 15: - case 85: + case 87: case 22: - case 90: - case 95: + case 92: + case 97: return true; } return ts.tokenIsIdentifierOrKeyword(token); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2, undefined); + initializeState("file.js", content, 2, true, undefined); var jsDocTypeExpression = parseJSDocTypeExpression(start, length); var diagnostics = parseDiagnostics; clearState(); @@ -9165,7 +9312,7 @@ var ts; function parseJSDocTypeExpression(start, length) { scanner.setText(sourceText, start, length); token = nextToken(); - var result = createNode(247); + var result = createNode(249); parseExpected(15); result.type = parseJSDocTopLevelType(); parseExpected(16); @@ -9175,13 +9322,13 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 46) { - var unionType = createNode(251, type.pos); + if (token === 47) { + var unionType = createNode(253, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 55) { - var optionalType = createNode(258, type.pos); + if (token === 56) { + var optionalType = createNode(260, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -9192,20 +9339,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 19) { - var arrayType = createNode(250, type.pos); + var arrayType = createNode(252, type.pos); arrayType.elementType = type; nextToken(); parseExpected(20); type = finishNode(arrayType); } - else if (token === 52) { - var nullableType = createNode(253, type.pos); + else if (token === 53) { + var nullableType = createNode(255, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 48) { - var nonNullableType = createNode(254, type.pos); + else if (token === 49) { + var nonNullableType = createNode(256, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -9220,80 +9367,80 @@ var ts; switch (token) { case 37: return parseJSDocAllType(); - case 52: + case 53: return parseJSDocUnknownOrNullableType(); case 17: return parseJSDocUnionType(); case 19: return parseJSDocTupleType(); - case 48: + case 49: return parseJSDocNonNullableType(); case 15: return parseJSDocRecordType(); - case 85: + case 87: return parseJSDocFunctionType(); case 22: return parseJSDocVariadicType(); - case 90: + case 92: return parseJSDocConstructorType(); - case 95: + case 97: return parseJSDocThisType(); - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: - case 101: + case 120: + case 131: + case 103: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(262); + var result = createNode(264); nextToken(); - parseExpected(53); + parseExpected(54); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(261); + var result = createNode(263); nextToken(); - parseExpected(53); + parseExpected(54); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(260); + var result = createNode(262); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(259); + var result = createNode(261); nextToken(); parseExpected(17); result.parameters = parseDelimitedList(22, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(18); - if (token === 53) { + if (token === 54) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(136); + var parameter = createNode(138); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(258, type.pos); + var result = createNode(260, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(257); + var result = createNode(259); result.name = parseSimplePropertyName(); while (parseOptional(21)) { if (token === 25) { @@ -9322,13 +9469,13 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(133, left.pos); + var result = createNode(135, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(255); + var result = createNode(257); nextToken(); result.members = parseDelimitedList(24, parseJSDocRecordMember); checkForTrailingComma(result.members); @@ -9336,22 +9483,22 @@ var ts; return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(256); + var result = createNode(258); result.name = parseSimplePropertyName(); - if (token === 53) { + if (token === 54) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(254); + var result = createNode(256); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(252); + var result = createNode(254); nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); @@ -9365,7 +9512,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(251); + var result = createNode(253); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(18); @@ -9376,14 +9523,14 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(46)) { + while (parseOptional(47)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(248); + var result = createNode(250); nextToken(); return finishNode(result); } @@ -9394,19 +9541,19 @@ var ts; token === 16 || token === 18 || token === 27 || - token === 55 || - token === 46) { - var result = createNode(249, pos); + token === 56 || + token === 47) { + var result = createNode(251, pos); return finishNode(result); } else { - var result = createNode(253, pos); + var result = createNode(255, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2, undefined); + initializeState("file.js", content, 2, true, undefined); var jsDocComment = parseJSDocComment(undefined, start, length); var diagnostics = parseDiagnostics; clearState(); @@ -9471,7 +9618,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(263, start); + var result = createNode(265, start); result.tags = tags; return finishNode(result, end); } @@ -9482,7 +9629,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64); - var atToken = createNode(54, pos - 1); + var atToken = createNode(55, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -9508,7 +9655,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(264, atToken.pos); + var result = createNode(266, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -9559,7 +9706,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(265, atToken.pos); + var result = createNode(267, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -9569,27 +9716,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 266; })) { + if (ts.forEach(tags, function (t) { return t.kind === 268; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(266, atToken.pos); + var result = createNode(268, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 267; })) { + if (ts.forEach(tags, function (t) { return t.kind === 269; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(267, atToken.pos); + var result = createNode(269, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 268; })) { + if (ts.forEach(tags, function (t) { return t.kind === 270; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -9602,7 +9749,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(135, name_9.pos); + var typeParameter = createNode(137, name_9.pos); typeParameter.name = name_9; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -9613,7 +9760,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(268, atToken.pos); + var result = createNode(270, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -9634,7 +9781,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(67, startPos); + var result = createNode(69, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -9710,7 +9857,7 @@ var ts; switch (node.kind) { case 9: case 8: - case 67: + case 69: return true; } return false; @@ -9928,16 +10075,16 @@ var ts; (function (ts) { ts.bindTime = 0; function getModuleInstanceState(node) { - if (node.kind === 213 || node.kind === 214) { + if (node.kind === 215 || node.kind === 216) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 220 || node.kind === 219) && !(node.flags & 1)) { + else if ((node.kind === 222 || node.kind === 221) && !(node.flags & 1)) { return 0; } - else if (node.kind === 217) { + else if (node.kind === 219) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -9953,7 +10100,7 @@ var ts; }); return state; } - else if (node.kind === 216) { + else if (node.kind === 218) { return getModuleInstanceState(node.body); } else { @@ -9972,6 +10119,8 @@ var ts; var container; var blockScopeContainer; var lastContainer; + var seenThisKeyword; + var isJavaScriptFile = ts.isSourceFileJavaScript(file); var inStrictMode = !!file.externalModuleIndicator; var symbolCount = 0; var Symbol = ts.objectAllocator.getSymbolConstructor(); @@ -10005,10 +10154,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 216 && node.name.kind === 9) { + if (node.kind === 218 && node.name.kind === 9) { return "\"" + node.name.text + "\""; } - if (node.name.kind === 134) { + if (node.name.kind === 136) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -10016,22 +10165,24 @@ var ts; return node.name.text; } switch (node.kind) { - case 142: + case 144: return "__constructor"; - case 150: - case 145: + case 152: + case 147: return "__call"; - case 151: - case 146: + case 153: + case 148: return "__new"; - case 147: + case 149: return "__index"; - case 226: + case 228: return "__export"; - case 225: + case 227: return node.isExportEquals ? "export=" : "default"; - case 211: - case 212: + case 181: + return "export="; + case 213: + case 214: return node.flags & 1024 ? "default" : undefined; } } @@ -10040,7 +10191,8 @@ var ts; } function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); - var name = node.flags & 1024 && parent ? "default" : getDeclarationName(node); + var isDefaultExport = node.flags & 1024; + var name = isDefaultExport && parent ? "default" : getDeclarationName(node); var symbol; if (name !== undefined) { symbol = ts.hasProperty(symbolTable, name) @@ -10056,6 +10208,11 @@ var ts; var message = symbol.flags & 2 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; + ts.forEach(symbol.declarations, function (declaration) { + if (declaration.flags & 1024) { + message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + } + }); ts.forEach(symbol.declarations, function (declaration) { file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); }); @@ -10073,7 +10230,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 228 || (node.kind === 219 && hasExportModifier)) { + if (node.kind === 230 || (node.kind === 221 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -10112,44 +10269,51 @@ var ts; blockScopeContainer = node; blockScopeContainer.locals = undefined; } - ts.forEachChild(node, bind); + if (node.kind === 215) { + seenThisKeyword = false; + ts.forEachChild(node, bind); + node.flags = seenThisKeyword ? node.flags | 524288 : node.flags & ~524288; + } + else { + ts.forEachChild(node, bind); + } container = saveContainer; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } function getContainerFlags(node) { switch (node.kind) { - case 184: - case 212: - case 213: + case 186: + case 214: case 215: - case 153: - case 163: + case 217: + case 155: + case 165: return 1; - case 145: - case 146: case 147: - case 141: - case 140: - case 211: - case 142: + case 148: + case 149: case 143: + case 142: + case 213: case 144: - case 150: - case 151: - case 171: - case 172: + case 145: + case 146: + case 152: + case 153: + case 173: + case 174: + case 218: + case 248: case 216: - case 246: - case 214: return 5; - case 242: - case 197: - case 198: + case 244: case 199: - case 218: + case 200: + case 201: + case 220: return 2; - case 190: + case 192: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -10165,33 +10329,33 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 216: + case 218: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 246: + case 248: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 184: - case 212: + case 186: + case 214: return declareClassMember(node, symbolFlags, symbolExcludes); - case 215: + case 217: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 153: - case 163: - case 213: + case 155: + case 165: + case 215: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 150: - case 151: - case 145: - case 146: + case 152: + case 153: case 147: - case 141: - case 140: - case 142: + case 148: + case 149: case 143: + case 142: case 144: - case 211: - case 171: - case 172: - case 214: + case 145: + case 146: + case 213: + case 173: + case 174: + case 216: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -10215,11 +10379,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 246 ? node : node.body; - if (body.kind === 246 || body.kind === 217) { + var body = node.kind === 248 ? node : node.body; + if (body.kind === 248 || body.kind === 219) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 226 || stat.kind === 225) { + if (stat.kind === 228 || stat.kind === 227) { return true; } } @@ -10274,11 +10438,11 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 67) { + if (prop.name.kind !== 69) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 243 || prop.kind === 244 || prop.kind === 141 + var currentKind = prop.kind === 245 || prop.kind === 246 || prop.kind === 143 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -10300,10 +10464,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 216: + case 218: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 246: + case 248: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -10321,8 +10485,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 104 && - node.originalKeywordKind <= 112 && + node.originalKeywordKind >= 106 && + node.originalKeywordKind <= 114 && !ts.isIdentifierName(node)) { if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -10349,17 +10513,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 67) { + if (inStrictMode && node.expression.kind === 69) { var span = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 67 && + return node.kind === 69 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 67) { + if (name && name.kind === 69) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span = ts.getErrorSpanForNode(file, name); @@ -10393,7 +10557,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 40 || node.operator === 41) { + if (node.operator === 41 || node.operator === 42) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -10422,17 +10586,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 246: - case 217: + case 248: + case 219: updateStrictModeStatementList(node.statements); return; - case 190: + case 192: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 212: - case 184: + case 214: + case 186: inStrictMode = true; return; } @@ -10455,102 +10619,122 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 67: + case 69: return checkStrictModeIdentifier(node); - case 179: + case 181: + if (isJavaScriptFile) { + if (ts.isExportsPropertyAssignment(node)) { + bindExportsPropertyAssignment(node); + } + else if (ts.isModuleExportsAssignment(node)) { + bindModuleExportsAssignment(node); + } + } return checkStrictModeBinaryExpression(node); - case 242: + case 244: return checkStrictModeCatchClause(node); - case 173: + case 175: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 178: + case 180: return checkStrictModePostfixUnaryExpression(node); - case 177: + case 179: return checkStrictModePrefixUnaryExpression(node); - case 203: + case 205: return checkStrictModeWithStatement(node); - case 135: + case 97: + seenThisKeyword = true; + return; + case 137: return declareSymbolAndAddToSymbolTable(node, 262144, 530912); - case 136: + case 138: return bindParameter(node); - case 209: - case 161: + case 211: + case 163: return bindVariableDeclarationOrBindingElement(node); - case 139: - case 138: + case 141: + case 140: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); - case 243: - case 244: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); case 245: + case 246: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 247: return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 145: - case 146: case 147: + case 148: + case 149: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 141: - case 140: + case 143: + case 142: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 211: + case 213: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16, 106927); - case 142: + case 144: return declareSymbolAndAddToSymbolTable(node, 16384, 0); - case 143: + case 145: return bindPropertyOrMethodOrAccessor(node, 32768, 41919); - case 144: + case 146: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 150: - case 151: - return bindFunctionOrConstructorType(node); + case 152: case 153: + return bindFunctionOrConstructorType(node); + case 155: return bindAnonymousDeclaration(node, 2048, "__type"); - case 163: + case 165: return bindObjectLiteralExpression(node); - case 171: - case 172: + case 173: + case 174: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16, bindingName); - case 184: - case 212: + case 168: + if (isJavaScriptFile) { + bindCallExpression(node); + } + break; + case 186: + case 214: return bindClassLikeDeclaration(node); - case 213: + case 215: return bindBlockScopedDeclaration(node, 64, 792960); - case 214: + case 216: return bindBlockScopedDeclaration(node, 524288, 793056); - case 215: + case 217: return bindEnumDeclaration(node); - case 216: + case 218: return bindModuleDeclaration(node); - case 219: - case 222: + case 221: case 224: - case 228: + case 226: + case 230: return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 221: + case 223: return bindImportClause(node); - case 226: + case 228: return bindExportDeclaration(node); - case 225: + case 227: return bindExportAssignment(node); - case 246: + case 248: return bindSourceFileIfExternalModule(); } } function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); + bindSourceFileAsExternalModule(); } } + function bindSourceFileAsExternalModule() { + bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); + } function bindExportAssignment(node) { + var boundExpression = node.kind === 227 ? node.expression : node.right; if (!container.symbol || !container.symbol.exports) { bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } - else if (node.expression.kind === 67) { + else if (boundExpression.kind === 69) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } else { @@ -10570,8 +10754,27 @@ var ts; declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); } } + function setCommonJsModuleIndicator(node) { + if (!file.commonJsModuleIndicator) { + file.commonJsModuleIndicator = node; + bindSourceFileAsExternalModule(); + } + } + function bindExportsPropertyAssignment(node) { + setCommonJsModuleIndicator(node); + declareSymbol(file.symbol.exports, file.symbol, node.left, 4 | 7340032, 0); + } + function bindModuleExportsAssignment(node) { + setCommonJsModuleIndicator(node); + bindExportAssignment(node); + } + function bindCallExpression(node) { + if (!file.commonJsModuleIndicator && ts.isRequireCall(node)) { + setCommonJsModuleIndicator(node); + } + } function bindClassLikeDeclaration(node) { - if (node.kind === 212) { + if (node.kind === 214) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -10624,7 +10827,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 1, 107455); } if (node.flags & 112 && - node.parent.kind === 142 && + node.parent.kind === 144 && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); @@ -10662,17 +10865,19 @@ var ts; var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); var typeCount = 0; + var symbolCount = 0; var emptyArray = []; var emptySymbols = {}; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; var emitResolver = createResolver(); var undefinedSymbol = createSymbol(4 | 67108864, "undefined"); var argumentsSymbol = createSymbol(4 | 67108864, "arguments"); var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, - getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount"); }, + getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, getTypeCount: function () { return typeCount; }, isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, @@ -10758,6 +10963,7 @@ var ts; var getInstantiatedGlobalPromiseLikeType; var getGlobalPromiseConstructorLikeType; var getGlobalThenableType; + var cjsRequireType; var tupleTypes = {}; var unionTypes = {}; var intersectionTypes = {}; @@ -10818,6 +11024,7 @@ var ts; diagnostics.add(diagnostic); } function createSymbol(flags, name) { + symbolCount++; return new Symbol(flags, name); } function getExcludedSymbolFlags(flags) { @@ -10946,10 +11153,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 246); + return ts.getAncestor(node, 248); } function isGlobalSourceFile(node) { - return node.kind === 246 && !ts.isExternalModule(node); + return node.kind === 248 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -10966,17 +11173,54 @@ var ts; } } } - function isDefinedBefore(node1, node2) { - var file1 = ts.getSourceFileOfNode(node1); - var file2 = ts.getSourceFileOfNode(node2); - if (file1 === file2) { - return node1.pos <= node2.pos; + function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { + var declarationFile = ts.getSourceFileOfNode(declaration); + var useFile = ts.getSourceFileOfNode(usage); + if (declarationFile !== useFile) { + if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) { + return true; + } + var sourceFiles = host.getSourceFiles(); + return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } - if (!compilerOptions.outFile && !compilerOptions.out) { - return true; + if (declaration.pos <= usage.pos) { + return declaration.kind !== 211 || + !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return isUsedInFunctionOrNonStaticProperty(declaration, usage); + function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + if (declaration.parent.parent.kind === 193 || + declaration.parent.parent.kind === 199) { + return isSameScopeDescendentOf(usage, declaration, container); + } + else if (declaration.parent.parent.kind === 201 || + declaration.parent.parent.kind === 200) { + var expression = declaration.parent.parent.expression; + return isSameScopeDescendentOf(usage, expression, container); + } + } + function isUsedInFunctionOrNonStaticProperty(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + var current = usage; + while (current) { + if (current === container) { + return false; + } + if (ts.isFunctionLike(current)) { + return true; + } + var initializerOfNonStaticProperty = current.parent && + current.parent.kind === 141 && + (current.parent.flags & 128) === 0 && + current.parent.initializer === current; + if (initializerOfNonStaticProperty) { + return true; + } + current = current.parent; + } + return false; } - var sourceFiles = host.getSourceFiles(); - return sourceFiles.indexOf(file1) <= sourceFiles.indexOf(file2); } function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { var result; @@ -10997,16 +11241,16 @@ var ts; } } switch (location.kind) { - case 246: - if (!ts.isExternalModule(location)) + case 248: + if (!ts.isExternalOrCommonJsModule(location)) break; - case 216: + case 218: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 246 || - (location.kind === 216 && location.name.kind === 9)) { + if (location.kind === 248 || + (location.kind === 218 && location.name.kind === 9)) { if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 228)) { + ts.getDeclarationOfKind(moduleExports[name], 230)) { break; } result = moduleExports["default"]; @@ -11020,13 +11264,13 @@ var ts; break loop; } break; - case 215: + case 217: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; - case 139: - case 138: + case 141: + case 140: if (ts.isClassLike(location.parent) && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -11036,9 +11280,9 @@ var ts; } } break; - case 212: - case 184: - case 213: + case 214: + case 186: + case 215: 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); @@ -11046,7 +11290,7 @@ var ts; } break loop; } - if (location.kind === 184 && meaning & 32) { + if (location.kind === 186 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -11054,28 +11298,28 @@ var ts; } } break; - case 134: + case 136: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 213) { + if (ts.isClassLike(grandparent) || grandparent.kind === 215) { 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 141: - case 140: - case 142: case 143: + case 142: case 144: - case 211: - case 172: + case 145: + case 146: + case 213: + case 174: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 171: + case 173: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -11088,8 +11332,8 @@ var ts; } } break; - case 137: - if (location.parent && location.parent.kind === 136) { + case 139: + if (location.parent && location.parent.kind === 138) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -11115,8 +11359,11 @@ var ts; error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); return undefined; } - if (meaning & 2 && result.flags & 2) { - checkResolvedBlockScopedVariable(result, errorLocation); + if (meaning & 2) { + var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); + if (exportOrLocalSymbol.flags & 2) { + checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); + } } } return result; @@ -11125,21 +11372,7 @@ var ts; ts.Debug.assert((result.flags & 2) !== 0); var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); - if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 209); - var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 191 || - variableDeclaration.parent.parent.kind === 197) { - isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); - } - else if (variableDeclaration.parent.parent.kind === 199 || - variableDeclaration.parent.parent.kind === 198) { - var expression = variableDeclaration.parent.parent.expression; - isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); - } - } - if (isUsedBeforeDeclaration) { + if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 211), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -11156,10 +11389,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 219) { + if (node.kind === 221) { return node; } - while (node && node.kind !== 220) { + while (node && node.kind !== 222) { node = node.parent; } return node; @@ -11169,7 +11402,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 230) { + if (node.moduleReference.kind === 232) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -11258,17 +11491,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 219: - return getTargetOfImportEqualsDeclaration(node); case 221: + return getTargetOfImportEqualsDeclaration(node); + case 223: return getTargetOfImportClause(node); - case 222: - return getTargetOfNamespaceImport(node); case 224: + return getTargetOfNamespaceImport(node); + case 226: return getTargetOfImportSpecifier(node); - case 228: + case 230: return getTargetOfExportSpecifier(node); - case 225: + case 227: return getTargetOfExportAssignment(node); } } @@ -11310,10 +11543,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 225) { + if (node.kind === 227) { checkExpressionCached(node.expression); } - else if (node.kind === 228) { + else if (node.kind === 230) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -11323,17 +11556,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 219); + importDeclaration = ts.getAncestor(entityName, 221); ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 67 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 69 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 67 || entityName.parent.kind === 133) { + if (entityName.kind === 69 || entityName.parent.kind === 135) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 219); + ts.Debug.assert(entityName.parent.kind === 221); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -11345,16 +11578,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 67) { + if (name.kind === 69) { var message = meaning === 1536 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 133 || name.kind === 164) { - var left = name.kind === 133 ? name.left : name.expression; - var right = name.kind === 133 ? name.right : name.name; + else if (name.kind === 135 || name.kind === 166) { + var left = name.kind === 135 ? name.left : name.expression; + var right = name.kind === 135 ? name.right : name.name; var namespace = resolveEntityName(left, 1536, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -11373,9 +11606,6 @@ var ts; ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); return symbol.flags & meaning ? symbol : resolveAlias(symbol); } - function isExternalModuleNameRelative(moduleName) { - return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; - } function resolveExternalModuleName(location, moduleReferenceExpression) { if (moduleReferenceExpression.kind !== 9) { return; @@ -11386,7 +11616,10 @@ var ts; if (moduleName === undefined) { return; } - var isRelative = isExternalModuleNameRelative(moduleName); + if (moduleName.indexOf("!") >= 0) { + moduleName = moduleName.substr(0, moduleName.indexOf("!")); + } + var isRelative = ts.isExternalModuleNameRelative(moduleName); if (!isRelative) { var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); if (symbol) { @@ -11490,7 +11723,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 142 && ts.nodeIsPresent(member.body)) { + if (member.kind === 144 && ts.nodeIsPresent(member.body)) { return member; } } @@ -11555,17 +11788,17 @@ var ts; } } switch (location_1.kind) { - case 246: - if (!ts.isExternalModule(location_1)) { + case 248: + if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 216: + case 218: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 212: - case 213: + case 214: + case 215: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -11598,7 +11831,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -11627,7 +11860,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -11682,8 +11915,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 216 && declaration.name.kind === 9) || - (declaration.kind === 246 && ts.isExternalModule(declaration)); + return (declaration.kind === 218 && declaration.name.kind === 9) || + (declaration.kind === 248 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -11715,11 +11948,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 152) { + if (entityName.parent.kind === 154) { meaning = 107455 | 1048576; } - else if (entityName.kind === 133 || entityName.kind === 164 || - entityName.parent.kind === 219) { + else if (entityName.kind === 135 || entityName.kind === 166 || + entityName.parent.kind === 221) { meaning = 1536; } else { @@ -11770,10 +12003,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 158) { + while (node.kind === 160) { node = node.parent; } - if (node.kind === 214) { + if (node.kind === 216) { return getSymbolOfNode(node); } } @@ -11787,10 +12020,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 184: + case 186: return "(Anonymous class)"; - case 171: - case 172: + case 173: + case 174: return "(Anonymous function)"; } } @@ -11851,6 +12084,7 @@ var ts; } function buildTypeDisplay(type, writer, enclosingDeclaration, globalFlags, symbolStack) { var globalFlagsToPass = globalFlags & 16; + var inObjectTypeLiteral = false; return writeType(type, globalFlags); function writeType(type, flags) { if (type.flags & 16777343) { @@ -11858,6 +12092,12 @@ var ts; ? "any" : type.intrinsicName); } + else if (type.flags & 33554432) { + if (inObjectTypeLiteral) { + writer.reportInaccessibleThisError(); + } + writer.writeKeyword("this"); + } else if (type.flags & 4096) { writeTypeReference(type, flags); } @@ -11896,9 +12136,9 @@ var ts; writeType(types[i], delimiter === 24 ? 0 : 64); } } - function writeSymbolTypeReference(symbol, typeArguments, pos, end) { - if (!isReservedMemberName(symbol.name)) { - buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056); + function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { + if (symbol.flags & 32 || !isReservedMemberName(symbol.name)) { + buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056, 0, flags); } if (pos < end) { writePunctuation(writer, 25); @@ -11912,7 +12152,7 @@ var ts; } } function writeTypeReference(type, flags) { - var typeArguments = type.typeArguments; + var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1)) { writeType(typeArguments[0], 64); writePunctuation(writer, 19); @@ -11930,12 +12170,13 @@ var ts; i++; } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_3, typeArguments, start, i); + writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); writePunctuation(writer, 21); } } } - writeSymbolTypeReference(type.symbol, typeArguments, i, typeArguments.length); + var typeParameterCount = (type.target.typeParameters || emptyArray).length; + writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags); } } function writeTupleType(type) { @@ -11947,7 +12188,7 @@ var ts; if (flags & 64) { writePunctuation(writer, 17); } - writeTypeList(type.types, type.flags & 16384 ? 46 : 45); + writeTypeList(type.types, type.flags & 16384 ? 47 : 46); if (flags & 64) { writePunctuation(writer, 18); } @@ -11967,7 +12208,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); } else { - writeKeyword(writer, 115); + writeKeyword(writer, 117); } } else { @@ -11988,7 +12229,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 246 || declaration.parent.kind === 217; + return declaration.parent.kind === 248 || declaration.parent.kind === 219; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -11997,7 +12238,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 99); + writeKeyword(writer, 101); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } @@ -12031,7 +12272,7 @@ var ts; if (flags & 64) { writePunctuation(writer, 17); } - writeKeyword(writer, 90); + writeKeyword(writer, 92); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); if (flags & 64) { @@ -12040,6 +12281,8 @@ var ts; return; } } + var saveInObjectTypeLiteral = inObjectTypeLiteral; + inObjectTypeLiteral = true; writePunctuation(writer, 15); writer.writeLine(); writer.increaseIndent(); @@ -12051,7 +12294,7 @@ var ts; } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 90); + writeKeyword(writer, 92); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 23); @@ -12060,11 +12303,11 @@ var ts; if (resolved.stringIndexType) { writePunctuation(writer, 19); writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); - writeKeyword(writer, 128); + writeKeyword(writer, 130); writePunctuation(writer, 20); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); writeType(resolved.stringIndexType, 0); writePunctuation(writer, 23); @@ -12073,11 +12316,11 @@ var ts; if (resolved.numberIndexType) { writePunctuation(writer, 19); writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); - writeKeyword(writer, 126); + writeKeyword(writer, 128); writePunctuation(writer, 20); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); writeType(resolved.numberIndexType, 0); writePunctuation(writer, 23); @@ -12092,7 +12335,7 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 23); @@ -12102,9 +12345,9 @@ var ts; else { buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); writeType(t, 0); writePunctuation(writer, 23); @@ -12113,6 +12356,7 @@ var ts; } writer.decreaseIndent(); writePunctuation(writer, 16); + inObjectTypeLiteral = saveInObjectTypeLiteral; } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { @@ -12126,7 +12370,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 81); + writeKeyword(writer, 83); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -12138,9 +12382,9 @@ var ts; } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } @@ -12187,14 +12431,14 @@ var ts; writePunctuation(writer, 34); } else { - writePunctuation(writer, 53); + writePunctuation(writer, 54); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 122); + writeKeyword(writer, 124); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -12228,13 +12472,13 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 216) { + if (node.kind === 218) { if (node.name.kind === 9) { return node; } } - else if (node.kind === 246) { - return ts.isExternalModule(node) ? node : undefined; + else if (node.kind === 248) { + return ts.isExternalOrCommonJsModule(node) ? node : undefined; } } ts.Debug.fail("getContainingModule cant reach here"); @@ -12276,59 +12520,59 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 161: + case 163: return isDeclarationVisible(node.parent.parent); - case 209: + case 211: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 216: - case 212: - case 213: + case 218: case 214: - case 211: case 215: - case 219: + case 216: + case 213: + case 217: + case 221: var parent_4 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 219 && parent_4.kind !== 246 && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 221 && parent_4.kind !== 248 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } return isDeclarationVisible(parent_4); - case 139: - case 138: - case 143: - case 144: case 141: case 140: + case 145: + case 146: + case 143: + case 142: if (node.flags & (32 | 64)) { return false; } - case 142: - case 146: - case 145: + case 144: + case 148: case 147: - case 136: - case 217: - case 150: - case 151: - case 153: case 149: - case 154: + case 138: + case 219: + case 152: + case 153: case 155: + case 151: case 156: case 157: case 158: + case 159: + case 160: return isDeclarationVisible(node.parent); - case 221: - case 222: + case 223: case 224: + case 226: return false; - case 135: - case 246: + case 137: + case 248: return true; - case 225: + case 227: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -12344,10 +12588,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 225) { + if (node.parent && node.parent.kind === 227) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 228) { + else if (node.parent.kind === 230) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -12422,7 +12666,7 @@ var ts; } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 209 ? node.parent.parent.parent : node.parent; + return node.kind === 211 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -12435,9 +12679,13 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1) !== 0; } + function getTypeForBindingElementParent(node) { + var symbol = getSymbolOfNode(node); + return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node); + } function getTypeForBindingElement(declaration) { var pattern = declaration.parent; - var parentType = getTypeForVariableLikeDeclaration(pattern.parent); + var parentType = getTypeForBindingElementParent(pattern.parent); if (parentType === unknownType) { return unknownType; } @@ -12448,7 +12696,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 159) { + if (pattern.kind === 161) { var name_11 = declaration.propertyName || declaration.name; type = getTypeOfPropertyOfType(parentType, name_11.text) || isNumericLiteralName(name_11.text) && getIndexTypeOfType(parentType, 1) || @@ -12482,10 +12730,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 198) { + if (declaration.parent.parent.kind === 200) { return anyType; } - if (declaration.parent.parent.kind === 199) { + if (declaration.parent.parent.kind === 201) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -12494,10 +12742,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 136) { + if (declaration.kind === 138) { var func = declaration.parent; - if (func.kind === 144 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143); + if (func.kind === 146 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -12510,7 +12758,7 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 244) { + if (declaration.kind === 246) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -12548,7 +12796,7 @@ var ts; if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; } - var elementTypes = ts.map(elements, function (e) { return e.kind === 185 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + var elementTypes = ts.map(elements, function (e) { return e.kind === 187 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); if (includePatternInType) { var result = createNewTupleType(elementTypes); result.pattern = pattern; @@ -12557,7 +12805,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern, includePatternInType) { - return pattern.kind === 159 + return pattern.kind === 161 ? getTypeFromObjectBindingPattern(pattern, includePatternInType) : getTypeFromArrayBindingPattern(pattern, includePatternInType); } @@ -12567,12 +12815,12 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 243 ? getWidenedType(type) : type; + return declaration.kind !== 245 ? getWidenedType(type) : type; } type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 136 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 138 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -12585,12 +12833,18 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 242) { + if (declaration.parent.kind === 244) { return links.type = anyType; } - if (declaration.kind === 225) { + if (declaration.kind === 227) { return links.type = checkExpression(declaration.expression); } + if (declaration.kind === 181) { + return links.type = checkExpression(declaration.right); + } + if (declaration.kind === 166) { + return checkExpressionCached(declaration.parent.right); + } if (!pushTypeResolution(symbol, 0)) { return unknownType; } @@ -12613,7 +12867,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 143) { + if (accessor.kind === 145) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -12629,8 +12883,8 @@ var ts; if (!pushTypeResolution(symbol, 0)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 143); - var setter = ts.getDeclarationOfKind(symbol, 144); + var getter = ts.getDeclarationOfKind(symbol, 145); + var setter = ts.getDeclarationOfKind(symbol, 146); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -12656,7 +12910,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 143); + var getter_1 = ts.getDeclarationOfKind(symbol, 145); error(getter_1, 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)); } } @@ -12745,9 +12999,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 212 || node.kind === 184 || - node.kind === 211 || node.kind === 171 || - node.kind === 141 || node.kind === 172) { + if (node.kind === 214 || node.kind === 186 || + node.kind === 213 || node.kind === 173 || + node.kind === 143 || node.kind === 174) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -12756,15 +13010,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 215); return appendOuterTypeParameters(undefined, declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 213 || node.kind === 212 || - node.kind === 184 || node.kind === 214) { + if (node.kind === 215 || node.kind === 214 || + node.kind === 186 || node.kind === 216) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -12869,7 +13123,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 213 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 215 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -12890,6 +13144,29 @@ var ts; } } } + function isIndependentInterface(symbol) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 215) { + if (declaration.flags & 524288) { + return false; + } + var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); + if (baseTypeNodes) { + for (var _b = 0; _b < baseTypeNodes.length; _b++) { + var node = baseTypeNodes[_b]; + if (ts.isSupportedExpressionWithTypeArguments(node)) { + var baseSymbol = resolveEntityName(node.expression, 793056, true); + if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + return false; + } + } + } + } + } + } + return true; + } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { @@ -12897,7 +13174,7 @@ var ts; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - if (outerTypeParameters || localTypeParameters) { + if (outerTypeParameters || localTypeParameters || kind === 1024 || !isIndependentInterface(symbol)) { type.flags |= 4096; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; @@ -12906,6 +13183,9 @@ var ts; type.instantiations[getTypeListId(type.typeParameters)] = type; type.target = type; type.typeArguments = type.typeParameters; + type.thisType = createType(512 | 33554432); + type.thisType.symbol = symbol; + type.thisType.constraint = getTypeWithThisArgument(type); } } return links.declaredType; @@ -12916,7 +13196,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 214); + var declaration = ts.getDeclarationOfKind(symbol, 216); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -12947,7 +13227,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 135).constraint) { + if (!ts.getDeclarationOfKind(symbol, 137).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -12980,6 +13260,66 @@ var ts; } return unknownType; } + function isIndependentTypeReference(node) { + if (node.typeArguments) { + for (var _i = 0, _a = node.typeArguments; _i < _a.length; _i++) { + var typeNode = _a[_i]; + if (!isIndependentType(typeNode)) { + return false; + } + } + } + return true; + } + function isIndependentType(node) { + switch (node.kind) { + case 117: + case 130: + case 128: + case 120: + case 131: + case 103: + case 9: + return true; + case 156: + return isIndependentType(node.elementType); + case 151: + return isIndependentTypeReference(node); + } + return false; + } + function isIndependentVariableLikeDeclaration(node) { + return node.type && isIndependentType(node.type) || !node.type && !node.initializer; + } + function isIndependentFunctionLikeDeclaration(node) { + if (node.kind !== 144 && (!node.type || !isIndependentType(node.type))) { + return false; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + if (!isIndependentVariableLikeDeclaration(parameter)) { + return false; + } + } + return true; + } + function isIndependentMember(symbol) { + if (symbol.declarations && symbol.declarations.length === 1) { + var declaration = symbol.declarations[0]; + if (declaration) { + switch (declaration.kind) { + case 141: + case 140: + return isIndependentVariableLikeDeclaration(declaration); + case 143: + case 142: + case 144: + return isIndependentFunctionLikeDeclaration(declaration); + } + } + } + return false; + } function createSymbolTable(symbols) { var result = {}; for (var _i = 0; _i < symbols.length; _i++) { @@ -12988,11 +13328,11 @@ var ts; } return result; } - function createInstantiatedSymbolTable(symbols, mapper) { + function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { var result = {}; for (var _i = 0; _i < symbols.length; _i++) { var symbol = symbols[_i]; - result[symbol.name] = instantiateSymbol(symbol, mapper); + result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } return result; } @@ -13023,44 +13363,54 @@ var ts; } return type; } - function resolveClassOrInterfaceMembers(type) { - var target = resolveDeclaredMembers(type); - var members = target.symbol.members; - var callSignatures = target.declaredCallSignatures; - var constructSignatures = target.declaredConstructSignatures; - var stringIndexType = target.declaredStringIndexType; - var numberIndexType = target.declaredNumberIndexType; - var baseTypes = getBaseTypes(target); + function getTypeWithThisArgument(type, thisArgument) { + if (type.flags & 4096) { + return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + } + return type; + } + function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) { + var mapper = identityMapper; + var members = source.symbol.members; + var callSignatures = source.declaredCallSignatures; + var constructSignatures = source.declaredConstructSignatures; + var stringIndexType = source.declaredStringIndexType; + var numberIndexType = source.declaredNumberIndexType; + if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { + mapper = createTypeMapper(typeParameters, typeArguments); + members = createInstantiatedSymbolTable(source.declaredProperties, mapper, typeParameters.length === 1); + callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); + constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); + stringIndexType = instantiateType(source.declaredStringIndexType, mapper); + numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); + } + var baseTypes = getBaseTypes(source); if (baseTypes.length) { - members = createSymbolTable(target.declaredProperties); + if (members === source.symbol.members) { + members = createSymbolTable(source.declaredProperties); + } + var thisArgument = ts.lastOrUndefined(typeArguments); for (var _i = 0; _i < baseTypes.length; _i++) { var baseType = baseTypes[_i]; - addInheritedMembers(members, getPropertiesOfObjectType(baseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(baseType, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(baseType, 1)); - stringIndexType = stringIndexType || getIndexTypeOfType(baseType, 0); - numberIndexType = numberIndexType || getIndexTypeOfType(baseType, 1); + var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; + addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); + stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0); + numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1); } } setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } + function resolveClassOrInterfaceMembers(type) { + resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); + } function resolveTypeReferenceMembers(type) { - var target = resolveDeclaredMembers(type.target); - var mapper = createTypeMapper(target.typeParameters, type.typeArguments); - var members = createInstantiatedSymbolTable(target.declaredProperties, mapper); - var callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); - var constructSignatures = instantiateList(target.declaredConstructSignatures, mapper, instantiateSignature); - var stringIndexType = target.declaredStringIndexType ? instantiateType(target.declaredStringIndexType, mapper) : undefined; - var numberIndexType = target.declaredNumberIndexType ? instantiateType(target.declaredNumberIndexType, mapper) : undefined; - ts.forEach(getBaseTypes(target), function (baseType) { - var instantiatedBaseType = instantiateType(baseType, mapper); - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1); - }); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var source = resolveDeclaredMembers(type.target); + var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); + var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? + type.typeArguments : ts.concatenate(type.typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); @@ -13109,7 +13459,8 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, true))); + var arrayElementType = getUnionType(type.elementTypes, true); + var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -13211,7 +13562,14 @@ var ts; var constructSignatures; var stringIndexType; var numberIndexType; - if (symbol.flags & 2048) { + if (type.target) { + members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false); + callSignatures = instantiateList(getSignaturesOfType(type.target, 0), type.mapper, instantiateSignature); + constructSignatures = instantiateList(getSignaturesOfType(type.target, 1), type.mapper, instantiateSignature); + stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0), type.mapper); + numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1), type.mapper); + } + else if (symbol.flags & 2048) { members = symbol.members; callSignatures = getSignaturesOfSymbol(members["__call"]); constructSignatures = getSignaturesOfSymbol(members["__new"]); @@ -13247,7 +13605,10 @@ var ts; } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & (1024 | 2048)) { + if (type.flags & 4096) { + resolveTypeReferenceMembers(type); + } + else if (type.flags & (1024 | 2048)) { resolveClassOrInterfaceMembers(type); } else if (type.flags & 65536) { @@ -13262,9 +13623,6 @@ var ts; else if (type.flags & 32768) { resolveIntersectionTypeMembers(type); } - else { - resolveTypeReferenceMembers(type); - } } return type; } @@ -13471,7 +13829,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 142 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 144 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -13502,7 +13860,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 148) { + if (declaration.type.kind === 150) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -13512,8 +13870,8 @@ var ts; } } else { - if (declaration.kind === 143 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 144); + if (declaration.kind === 145 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 146); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -13531,19 +13889,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 150: - case 151: - case 211: - case 141: - case 140: + case 152: + case 153: + case 213: + case 143: case 142: + case 144: + case 147: + case 148: + case 149: case 145: case 146: - case 147: - case 143: - case 144: - case 171: - case 172: + case 173: + case 174: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -13555,6 +13913,16 @@ var ts; } return result; } + function resolveExternalModuleTypeByLiteral(name) { + var moduleSym = resolveExternalModuleName(name, name); + if (moduleSym) { + var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); + if (resolvedModuleSymbol) { + return getTypeOfSymbol(resolvedModuleSymbol); + } + } + return anyType; + } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3)) { @@ -13613,7 +13981,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 142 || signature.declaration.kind === 146; + var isConstructor = signature.declaration.kind === 144 || signature.declaration.kind === 148; var type = createObjectType(65536 | 262144); type.members = emptySymbols; type.properties = emptyArray; @@ -13627,7 +13995,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 126 : 128; + var syntaxKind = kind === 1 ? 128 : 130; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -13656,30 +14024,33 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 137).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137).parent); } function getTypeListId(types) { - switch (types.length) { - case 1: - return "" + types[0].id; - case 2: - return types[0].id + "," + types[1].id; - default: - var result = ""; - for (var i = 0; i < types.length; i++) { - if (i > 0) { - result += ","; + if (types) { + switch (types.length) { + case 1: + return "" + types[0].id; + case 2: + return types[0].id + "," + types[1].id; + default: + var result = ""; + for (var i = 0; i < types.length; i++) { + if (i > 0) { + result += ","; + } + result += types[i].id; } - result += types[i].id; - } - return result; + return result; + } } + return ""; } function getPropagatingFlagsOfTypes(types) { var result = 0; @@ -13693,7 +14064,7 @@ var ts; var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 | getPropagatingFlagsOfTypes(typeArguments); + var flags = 4096 | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -13709,13 +14080,13 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 137; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 149 && n.typeName.kind === 67) { + if (n.kind === 151 && n.typeName.kind === 69) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); @@ -13782,7 +14153,7 @@ var ts; function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var typeNameOrExpression = node.kind === 149 ? node.typeName : + var typeNameOrExpression = node.kind === 151 ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; @@ -13808,9 +14179,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 212: - case 213: + case 214: case 215: + case 217: return declaration; } } @@ -13847,10 +14218,13 @@ var ts; return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056, undefined), arity); } function getExportedTypeFromNamespace(namespace, name) { - var namespaceSymbol = getGlobalSymbol(namespace, 1536, undefined); - var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056); + var typeSymbol = getExportedSymbolFromNamespace(namespace, name); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } + function getExportedSymbolFromNamespace(namespace, name) { + var namespaceSymbol = getGlobalSymbol(namespace, 1536, undefined); + return namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 | 107455); + } function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } @@ -13860,17 +14234,17 @@ var ts; ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) : emptyObjectType; } - function createTypeFromGenericGlobalType(genericGlobalType, elementType) { - return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, [elementType]) : emptyObjectType; + function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { + return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; } function createIterableType(elementType) { - return createTypeFromGenericGlobalType(globalIterableType, elementType); + return createTypeFromGenericGlobalType(globalIterableType, [elementType]); } function createIterableIteratorType(elementType) { - return createTypeFromGenericGlobalType(globalIterableIteratorType, elementType); + return createTypeFromGenericGlobalType(globalIterableIteratorType, [elementType]); } function createArrayType(elementType) { - return createTypeFromGenericGlobalType(globalArrayType, elementType); + return createTypeFromGenericGlobalType(globalArrayType, [elementType]); } function getTypeFromArrayTypeNode(node) { var links = getNodeLinks(node); @@ -14027,46 +14401,66 @@ var ts; } return links.resolvedType; } + function getThisType(node) { + var container = ts.getThisContainer(node, false); + var parent = container && container.parent; + if (parent && (ts.isClassLike(parent) || parent.kind === 215)) { + if (!(container.flags & 128)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; + } + } + error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); + return unknownType; + } + function getTypeFromThisTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getThisType(node); + } + return links.resolvedType; + } function getTypeFromTypeNode(node) { switch (node.kind) { - case 115: + case 117: return anyType; - case 128: + case 130: return stringType; - case 126: + case 128: return numberType; - case 118: + case 120: return booleanType; - case 129: + case 131: return esSymbolType; - case 101: + case 103: return voidType; + case 97: + return getTypeFromThisTypeNode(node); case 9: return getTypeFromStringLiteral(node); - case 149: + case 151: return getTypeFromTypeReference(node); - case 148: + case 150: return booleanType; - case 186: + case 188: return getTypeFromTypeReference(node); - case 152: - return getTypeFromTypeQueryNode(node); case 154: + return getTypeFromTypeQueryNode(node); + case 156: return getTypeFromArrayTypeNode(node); - case 155: + case 157: return getTypeFromTupleTypeNode(node); - case 156: + case 158: return getTypeFromUnionTypeNode(node); - case 157: + case 159: return getTypeFromIntersectionTypeNode(node); - case 158: + case 160: return getTypeFromTypeNode(node.type); - case 150: - case 151: + case 152: case 153: + case 155: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 67: - case 133: + case 69: + case 135: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -14170,7 +14564,7 @@ var ts; type: instantiateType(signature.typePredicate.type, mapper) }; } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -14202,21 +14596,13 @@ var ts; mapper.instantiations = []; } var result = createObjectType(65536 | 131072, type.symbol); - result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); - result.members = createSymbolTable(result.properties); - result.callSignatures = instantiateList(getSignaturesOfType(type, 0), mapper, instantiateSignature); - result.constructSignatures = instantiateList(getSignaturesOfType(type, 1), mapper, instantiateSignature); - var stringIndexType = getIndexTypeOfType(type, 0); - var numberIndexType = getIndexTypeOfType(type, 1); - if (stringIndexType) - result.stringIndexType = instantiateType(stringIndexType, mapper); - if (numberIndexType) - result.numberIndexType = instantiateType(numberIndexType, mapper); + result.target = type; + result.mapper = mapper; mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { - if (mapper !== identityMapper) { + if (type && mapper !== identityMapper) { if (type.flags & 512) { return mapper(type); } @@ -14240,27 +14626,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 171: - case 172: + case 173: + case 174: return isContextSensitiveFunctionLikeDeclaration(node); - case 163: + case 165: return ts.forEach(node.properties, isContextSensitive); - case 162: + case 164: return ts.forEach(node.elements, isContextSensitive); - case 180: + case 182: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 179: - return node.operatorToken.kind === 51 && + case 181: + return node.operatorToken.kind === 52 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 243: + case 245: return isContextSensitive(node.initializer); - case 141: - case 140: + case 143: + case 142: return isContextSensitiveFunctionLikeDeclaration(node); - case 170: + case 172: return isContextSensitive(node.expression); } return false; @@ -14413,7 +14799,7 @@ var ts; } else { if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { return result; } } @@ -14435,7 +14821,7 @@ var ts; var result; if (source.flags & 80896 && target.flags & 80896) { if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, false)) { + if (result = typeArgumentsRelatedTo(source, target, false)) { return result; } } @@ -14545,9 +14931,14 @@ var ts; } return result; } - function typesRelatedTo(sources, targets, reportErrors) { + function typeArgumentsRelatedTo(source, target, reportErrors) { + var sources = source.typeArguments || emptyArray; + var targets = target.typeArguments || emptyArray; + if (sources.length !== targets.length && relation === identityRelation) { + return 0; + } var result = -1; - for (var i = 0, len = sources.length; i < len; i++) { + for (var i = 0; i < targets.length; i++) { var related = isRelatedTo(sources[i], targets[i], reportErrors); if (!related) { return 0; @@ -15198,22 +15589,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 139: - case 138: + case 141: + case 140: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 136: + case 138: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 211: - case 141: - case 140: + case 213: case 143: - case 144: - case 171: - case 172: + case 142: + case 145: + case 146: + case 173: + case 174: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -15309,9 +15700,10 @@ var ts; } } 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++) { + var sourceTypes = source.typeArguments || emptyArray; + var targetTypes = target.typeArguments || emptyArray; + var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; + for (var i = 0; i < count; i++) { inferFromTypes(sourceTypes[i], targetTypes[i]); } } @@ -15465,10 +15857,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 152: + case 154: return true; - case 67: - case 133: + case 69: + case 135: node = node.parent; continue; default: @@ -15508,12 +15900,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 55 && node.operatorToken.kind <= 66) { + if (node.operatorToken.kind >= 56 && node.operatorToken.kind <= 68) { var n = node.left; - while (n.kind === 170) { + while (n.kind === 172) { n = n.expression; } - if (n.kind === 67 && getResolvedSymbol(n) === symbol) { + if (n.kind === 69 && getResolvedSymbol(n) === symbol) { return true; } } @@ -15527,55 +15919,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 179: + case 181: return isAssignedInBinaryExpression(node); - case 209: - case 161: + case 211: + case 163: return isAssignedInVariableDeclaration(node); - case 159: - case 160: + case 161: case 162: - case 163: case 164: case 165: case 166: case 167: + case 168: case 169: - case 187: - case 170: - case 177: - case 173: - case 176: - case 174: + case 171: + case 189: + case 172: + case 179: case 175: case 178: - case 182: + case 176: + case 177: case 180: - case 183: - case 190: - case 191: + case 184: + case 182: + case 185: + case 192: case 193: - case 194: case 195: case 196: case 197: case 198: case 199: - case 202: - case 203: + case 200: + case 201: case 204: - case 239: - case 240: case 205: case 206: - case 207: + case 241: case 242: - case 231: - case 232: - case 236: - case 237: + case 207: + case 208: + case 209: + case 244: case 233: + case 234: case 238: + case 239: + case 235: + case 240: return ts.forEachChild(node, isAssignedIn); } return false; @@ -15590,34 +15982,34 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 194: + case 196: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 180: + case 182: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 179: + case 181: if (child === node.right) { - if (node.operatorToken.kind === 50) { + if (node.operatorToken.kind === 51) { narrowedType = narrowType(type, node.left, true); } - else if (node.operatorToken.kind === 51) { + else if (node.operatorToken.kind === 52) { narrowedType = narrowType(type, node.left, false); } } break; - case 246: - case 216: - case 211: - case 141: - case 140: + case 248: + case 218: + case 213: case 143: - case 144: case 142: + case 145: + case 146: + case 144: break loop; } if (narrowedType !== type) { @@ -15631,12 +16023,12 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 174 || expr.right.kind !== 9) { + if (expr.left.kind !== 176 || expr.right.kind !== 9) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 67 || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 69 || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; @@ -15682,7 +16074,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 69 || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -15746,27 +16138,27 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 166: + case 168: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 170: + case 172: return narrowType(type, expr.expression, assumeTrue); - case 179: + case 181: var operator = expr.operatorToken.kind; if (operator === 32 || operator === 33) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 50) { + else if (operator === 51) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 51) { + else if (operator === 52) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 89) { + else if (operator === 91) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 177: - if (expr.operator === 48) { + case 179: + if (expr.operator === 49) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -15778,7 +16170,7 @@ var ts; var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 172) { + if (container.kind === 174) { if (languageVersion < 2) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -15809,15 +16201,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 242) { + symbol.valueDeclaration.parent.kind === 244) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 210) { + while (container.kind !== 212) { container = container.parent; } container = container.parent; - if (container.kind === 191) { + if (container.kind === 193) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -15835,7 +16227,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 139 || container.kind === 142) { + if (container.kind === 141 || container.kind === 144) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -15846,29 +16238,29 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 172) { + if (container.kind === 174) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 216: + case 218: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 215: + case 217: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 142: + case 144: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 139: - case 138: + case 141: + case 140: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 134: + case 136: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -15877,27 +16269,27 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); + return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } return anyType; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 136) { + if (n.kind === 138) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 166 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 168 && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 172) { + while (container && container.kind === 174) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -15923,7 +16315,7 @@ var ts; return unknownType; } if (!canUseSuperExpression) { - if (container && container.kind === 134) { + if (container && container.kind === 136) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -15934,7 +16326,7 @@ var ts; } return unknownType; } - if (container.kind === 142 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 144 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -15946,24 +16338,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 142; + return container.kind === 144; } else { if (container && ts.isClassLike(container.parent)) { if (container.flags & 128) { - return container.kind === 141 || - container.kind === 140 || - container.kind === 143 || - container.kind === 144; + return container.kind === 143 || + container.kind === 142 || + container.kind === 145 || + container.kind === 146; } else { - return container.kind === 141 || + return container.kind === 143 || + container.kind === 142 || + container.kind === 145 || + container.kind === 146 || + container.kind === 141 || container.kind === 140 || - container.kind === 143 || - container.kind === 144 || - container.kind === 139 || - container.kind === 138 || - container.kind === 142; + container.kind === 144; } } } @@ -15997,7 +16389,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 136) { + if (declaration.kind === 138) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -16030,7 +16422,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 136 && node.parent.initializer === node) { + if (node.parent.kind === 138 && node.parent.initializer === node) { return true; } node = node.parent; @@ -16039,8 +16431,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 142 || - functionDecl.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144))) { + functionDecl.kind === 144 || + functionDecl.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -16059,7 +16451,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 168) { + if (template.parent.kind === 170) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -16067,12 +16459,12 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 55 && operator <= 66) { + if (operator >= 56 && operator <= 68) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 51) { + else if (operator === 52) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); @@ -16159,7 +16551,7 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxExpression(expr) { - if (expr.parent.kind === 236) { + if (expr.parent.kind === 238) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -16169,7 +16561,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 237) { + if (expr.kind === 239) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -16187,38 +16579,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 209: - case 136: - case 139: + case 211: case 138: - case 161: + case 141: + case 140: + case 163: return getContextualTypeForInitializerExpression(node); - case 172: - case 202: + case 174: + case 204: return getContextualTypeForReturnExpression(node); - case 182: + case 184: return getContextualTypeForYieldOperand(parent); - case 166: - case 167: - return getContextualTypeForArgument(parent, node); + case 168: case 169: - case 187: + return getContextualTypeForArgument(parent, node); + case 171: + case 189: return getTypeFromTypeNode(parent.type); - case 179: + case 181: return getContextualTypeForBinaryOperand(node); - case 243: + case 245: return getContextualTypeForObjectLiteralElement(parent); - case 162: + case 164: return getContextualTypeForElementExpression(node); - case 180: + case 182: return getContextualTypeForConditionalOperand(node); - case 188: - ts.Debug.assert(parent.parent.kind === 181); + case 190: + ts.Debug.assert(parent.parent.kind === 183); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 170: + case 172: return getContextualType(parent); - case 238: - case 237: + case 240: + case 239: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -16233,7 +16625,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 171 || node.kind === 172; + return node.kind === 173 || node.kind === 174; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -16241,7 +16633,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -16281,13 +16673,13 @@ var ts; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 179 && parent.operatorToken.kind === 55 && parent.left === node) { + if (parent.kind === 181 && parent.operatorToken.kind === 56 && parent.left === node) { return true; } - if (parent.kind === 243) { + if (parent.kind === 245) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 162) { + if (parent.kind === 164) { return isAssignmentTarget(parent); } return false; @@ -16297,8 +16689,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 161 && !!node.initializer) || - (node.kind === 179 && node.operatorToken.kind === 55); + return (node.kind === 163 && !!node.initializer) || + (node.kind === 181 && node.operatorToken.kind === 56); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -16307,7 +16699,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 183) { + if (inDestructuringPattern && e.kind === 185) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -16319,7 +16711,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 183; + hasSpreadElement = hasSpreadElement || e.kind === 185; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -16330,7 +16722,7 @@ var ts; var contextualType = getContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 160 || pattern.kind === 162)) { + if (pattern && (pattern.kind === 162 || pattern.kind === 164)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -16338,7 +16730,7 @@ var ts; elementTypes.push(contextualType.elementTypes[i]); } else { - if (patternElement.kind !== 185) { + if (patternElement.kind !== 187) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -16353,7 +16745,7 @@ var ts; return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 134 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 136 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); @@ -16378,35 +16770,37 @@ var ts; return links.resolvedType; } function checkObjectLiteral(node, contextualMapper) { - checkGrammarObjectLiteralExpression(node); + var inDestructuringPattern = isAssignmentTarget(node); + checkGrammarObjectLiteralExpression(node, inDestructuringPattern); var propertiesTable = {}; var propertiesArray = []; var contextualType = getContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 159 || contextualType.pattern.kind === 163); - var inDestructuringPattern = isAssignmentTarget(node); + (contextualType.pattern.kind === 161 || contextualType.pattern.kind === 165); var typeFlags = 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 243 || - memberDecl.kind === 244 || + if (memberDecl.kind === 245 || + memberDecl.kind === 246 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 243) { + if (memberDecl.kind === 245) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 141) { + else if (memberDecl.kind === 143) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 244); + ts.Debug.assert(memberDecl.kind === 246); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 | 67108864 | member.flags, member.name); if (inDestructuringPattern) { - if (memberDecl.kind === 243 && hasDefaultValue(memberDecl.initializer)) { + var isOptional = (memberDecl.kind === 245 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 246 && memberDecl.objectAssignmentInitializer); + if (isOptional) { prop.flags |= 536870912; } } @@ -16429,7 +16823,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 143 || memberDecl.kind === 144); + ts.Debug.assert(memberDecl.kind === 145 || memberDecl.kind === 146); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -16485,7 +16879,7 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 67) { + if (lhs.kind === 69) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && @@ -16502,17 +16896,17 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 238: + case 240: checkJsxExpression(child); break; - case 231: + case 233: checkJsxElement(child); break; - case 232: + case 234: checkJsxSelfClosingElement(child); break; default: - ts.Debug.assert(child.kind === 234); + ts.Debug.assert(child.kind === 236); } } return jsxElementType || anyType; @@ -16521,7 +16915,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 133) { + if (tagName.kind === 135) { return false; } else { @@ -16622,12 +17016,14 @@ var ts; var valueSymbol = resolveJsxTagName(node); if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4; - getSymbolLinks(valueSymbol).referenced = true; + if (valueSymbol.flags & 8388608) { + markAliasSymbolAsReferenced(valueSymbol); + } } return valueSymbol || unknownSymbol; } function resolveJsxTagName(node) { - if (node.tagName.kind === 67) { + if (node.tagName.kind === 69) { var tag = node.tagName; var sym = getResolvedSymbol(tag); return sym.exportSymbol || sym; @@ -16767,11 +17163,11 @@ var ts; var nameTable = {}; var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 236) { + if (node.attributes[i].kind === 238) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 237); + ts.Debug.assert(node.attributes[i].kind === 239); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -16797,7 +17193,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 139; + return s.valueDeclaration ? s.valueDeclaration.kind : 141; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -16805,11 +17201,11 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 93) { - var errorNode = node.kind === 164 ? + if (left.kind === 95) { + var errorNode = node.kind === 166 ? node.name : node.right; - if (getDeclarationKindFromSymbol(prop) !== 141) { + if (getDeclarationKindFromSymbol(prop) !== 143) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -16830,7 +17226,7 @@ var ts; } return true; } - if (left.kind === 93) { + if (left.kind === 95) { return true; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -16840,6 +17236,9 @@ var ts; if (flags & 128) { return true; } + if (type.flags & 33554432) { + type = getConstraintOfTypeParameter(type); + } if (!(getTargetType(type).flags & (1024 | 2048) && hasBaseType(type, enclosingClass))) { error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); return false; @@ -16864,18 +17263,18 @@ var ts; var prop = getPropertyOfType(apparentType, right.text); if (!prop) { if (right.text) { - error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type)); + error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type.flags & 33554432 ? apparentType : type)); } return unknownType; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { - checkClassPropertyAccess(node, left, type, prop); + checkClassPropertyAccess(node, left, apparentType, prop); } return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 164 + var left = node.kind === 166 ? node.expression : node.left; var type = checkExpression(left); @@ -16890,7 +17289,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 167 && node.parent.expression === node) { + if (node.parent.kind === 169 && 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); @@ -16949,6 +17348,12 @@ var ts; if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } + if (indexArgumentExpression.kind === 167 || indexArgumentExpression.kind === 166) { + var value = getConstantValue(indexArgumentExpression); + if (value !== undefined) { + return value.toString(); + } + } if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { var rightHandSideName = indexArgumentExpression.name.text; return ts.getPropertyNameForKnownSymbolName(rightHandSideName); @@ -16986,10 +17391,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 168) { + if (node.kind === 170) { checkExpression(node.template); } - else if (node.kind !== 137) { + else if (node.kind !== 139) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -17040,7 +17445,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 183) { + if (arg && arg.kind === 185) { return i; } } @@ -17052,11 +17457,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 168) { + if (node.kind === 170) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 181) { + if (tagExpression.template.kind === 183) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -17068,7 +17473,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 137) { + else if (node.kind === 139) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); @@ -17076,7 +17481,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 167); + ts.Debug.assert(callExpression.kind === 169); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -17129,7 +17534,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 185) { + if (arg === undefined || arg.kind !== 187) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -17176,7 +17581,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 185) { + if (arg === undefined || arg.kind !== 187) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -17195,16 +17600,16 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 168) { + if (node.kind === 170) { var template = node.template; args = [undefined]; - if (template.kind === 181) { + if (template.kind === 183) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 137) { + else if (node.kind === 139) { return undefined; } else { @@ -17213,18 +17618,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 137) { + if (node.kind === 139) { switch (node.parent.kind) { - case 212: - case 184: + case 214: + case 186: return 1; - case 139: - return 2; case 141: + return 2; case 143: - case 144: + case 145: + case 146: + if (languageVersion === 0) { + return 2; + } return signature.parameters.length >= 3 ? 3 : 2; - case 136: + case 138: return 3; } } @@ -17234,20 +17642,20 @@ var ts; } function getEffectiveDecoratorFirstArgumentType(node) { switch (node.kind) { - case 212: - case 184: + case 214: + case 186: var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 136: + case 138: node = node.parent; - if (node.kind === 142) { + if (node.kind === 144) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } - case 139: case 141: case 143: - case 144: + case 145: + case 146: return getParentTypeOfClassElement(node); default: ts.Debug.fail("Unsupported decorator target."); @@ -17256,25 +17664,25 @@ var ts; } function getEffectiveDecoratorSecondArgumentType(node) { switch (node.kind) { - case 212: + case 214: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 136: + case 138: node = node.parent; - if (node.kind === 142) { + if (node.kind === 144) { return anyType; } - case 139: case 141: case 143: - case 144: + case 145: + case 146: var element = node; switch (element.name.kind) { - case 67: + case 69: case 8: case 9: return getStringLiteralType(element.name); - case 134: + case 136: var nameType = checkComputedPropertyName(element.name); if (allConstituentTypesHaveKind(nameType, 16777216)) { return nameType; @@ -17293,17 +17701,17 @@ var ts; } function getEffectiveDecoratorThirdArgumentType(node) { switch (node.kind) { - case 212: + case 214: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 136: + case 138: return numberType; - case 139: + case 141: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 141: case 143: - case 144: + case 145: + case 146: var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); default: @@ -17325,26 +17733,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 137) { + if (node.kind === 139) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 168) { + else if (argIndex === 0 && node.kind === 170) { return globalTemplateStringsArrayType; } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 137 || - (argIndex === 0 && node.kind === 168)) { + if (node.kind === 139 || + (argIndex === 0 && node.kind === 170)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 137) { + if (node.kind === 139) { return node.expression; } - else if (argIndex === 0 && node.kind === 168) { + else if (argIndex === 0 && node.kind === 170) { return node.template; } else { @@ -17352,12 +17760,12 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 168; - var isDecorator = node.kind === 137; + var isTaggedTemplate = node.kind === 170; + var isDecorator = node.kind === 139; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; - if (node.expression.kind !== 93) { + if (node.expression.kind !== 95) { ts.forEach(typeArguments, checkSourceElement); } } @@ -17495,7 +17903,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 93) { + if (node.expression.kind === 95) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -17584,16 +17992,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 212: - case 184: + case 214: + case 186: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 136: + case 138: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 139: - return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; case 141: + return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; case 143: - case 144: + case 145: + case 146: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -17621,16 +18029,16 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 166) { + if (node.kind === 168) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 167) { + else if (node.kind === 169) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 168) { + else if (node.kind === 170) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 137) { + else if (node.kind === 139) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -17642,21 +18050,24 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 93) { + if (node.expression.kind === 95) { return voidType; } - if (node.kind === 167) { + if (node.kind === 169) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 142 && - declaration.kind !== 146 && - declaration.kind !== 151) { + declaration.kind !== 144 && + declaration.kind !== 148 && + declaration.kind !== 153) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } return anyType; } } + if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node)) { + return resolveExternalModuleTypeByLiteral(node.arguments[0]); + } return getReturnTypeOfSignature(signature); } function checkTaggedTemplateExpression(node) { @@ -17691,10 +18102,22 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } } + function assignBindingElementTypes(node) { + if (ts.isBindingPattern(node.name)) { + for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 187) { + getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); + assignBindingElementTypes(element); + } + } + } + } function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { var links = getSymbolLinks(parameter); if (!links.type) { links.type = instantiateType(contextualType, mapper); + assignBindingElementTypes(parameter.valueDeclaration); } else if (isInferentialContext(mapper)) { inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); @@ -17715,7 +18138,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 190) { + if (func.body.kind !== 192) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -17819,7 +18242,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 206); + return (body.statements.length === 1) && (body.statements[0].kind === 208); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -17828,7 +18251,7 @@ var ts; if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 190) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192) { return; } var bodyBlock = func.body; @@ -17841,9 +18264,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 !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 171) { + if (!hasGrammarError && node.kind === 173) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -17879,14 +18302,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 141 && node.kind !== 140) { + if (produceDiagnostics && node.kind !== 143 && node.kind !== 142) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -17903,7 +18326,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 190) { + if (node.body.kind === 192) { checkSourceElement(node.body); } else { @@ -17935,17 +18358,17 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 67: { + case 69: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 164: { + case 166: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 165: + case 167: return true; - case 170: + case 172: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -17953,12 +18376,12 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 67: - case 164: { + case 69: + case 166: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; } - case 165: { + case 167: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 9) { @@ -17968,7 +18391,7 @@ var ts; } return false; } - case 170: + case 172: return isConstVariableReference(n.expression); default: return false; @@ -18013,15 +18436,15 @@ var ts; switch (node.operator) { case 35: case 36: - case 49: + case 50: if (someConstituentTypeHasKind(operandType, 16777216)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 48: + case 49: return booleanType; - case 40: case 41: + case 42: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); @@ -18076,21 +18499,21 @@ var ts; function isConstEnumSymbol(symbol) { return (symbol.flags & 128) !== 0; } - function checkInstanceOfExpression(node, leftType, rightType) { + function checkInstanceOfExpression(left, right, leftType, rightType) { if (allConstituentTypesHaveKind(leftType, 16777726)) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); + error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; } - function checkInExpression(node, leftType, rightType) { + function checkInExpression(left, right, leftType, rightType) { if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 16777216)) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); + error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } @@ -18098,7 +18521,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 243 || p.kind === 244) { + if (p.kind === 245 || p.kind === 246) { var name_14 = p.name; var type = isTypeAny(sourceType) ? sourceType @@ -18106,7 +18529,12 @@ var ts; isNumericLiteralName(name_14.text) && getIndexTypeOfType(sourceType, 1) || getIndexTypeOfType(sourceType, 0); if (type) { - checkDestructuringAssignment(p.initializer || name_14, type); + if (p.kind === 246) { + checkDestructuringAssignment(p, type); + } + else { + checkDestructuringAssignment(p.initializer || name_14, type); + } } else { error(name_14, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_14)); @@ -18123,8 +18551,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 185) { - if (e.kind !== 183) { + if (e.kind !== 187) { + if (e.kind !== 185) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -18149,7 +18577,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 179 && restExpression.operatorToken.kind === 55) { + if (restExpression.kind === 181 && restExpression.operatorToken.kind === 56) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -18161,15 +18589,26 @@ var ts; } return sourceType; } - function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 179 && target.operatorToken.kind === 55) { + function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { + var target; + if (exprOrAssignment.kind === 246) { + var prop = exprOrAssignment; + if (prop.objectAssignmentInitializer) { + checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); + } + target = exprOrAssignment.name; + } + else { + target = exprOrAssignment; + } + if (target.kind === 181 && target.operatorToken.kind === 56) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 163) { + if (target.kind === 165) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 162) { + if (target.kind === 164) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -18182,33 +18621,38 @@ var ts; return sourceType; } function checkBinaryExpression(node, contextualMapper) { - var operator = node.operatorToken.kind; - if (operator === 55 && (node.left.kind === 163 || node.left.kind === 162)) { - return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); + return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); + } + function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { + var operator = operatorToken.kind; + if (operator === 56 && (left.kind === 165 || left.kind === 164)) { + return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } - var leftType = checkExpression(node.left, contextualMapper); - var rightType = checkExpression(node.right, contextualMapper); + var leftType = checkExpression(left, contextualMapper); + var rightType = checkExpression(right, contextualMapper); switch (operator) { case 37: - case 58: case 38: case 59: - case 39: case 60: - case 36: - case 57: - case 42: + case 39: case 61: - case 43: + case 40: case 62: - case 44: + case 36: + case 58: + case 43: case 63: - case 46: + case 44: + case 64: + case 45: case 65: case 47: + case 67: + case 48: + case 68: + case 46: case 66: - case 45: - case 64: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -18216,19 +18660,19 @@ var ts; var suggestedOperator; if ((leftType.flags & 8) && (rightType.flags & 8) && - (suggestedOperator = getSuggestedBooleanOperator(node.operatorToken.kind)) !== undefined) { - error(node, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(node.operatorToken.kind), ts.tokenToString(suggestedOperator)); + (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { + error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); } else { - var leftOk = checkArithmeticOperandType(node.left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(node.right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); if (leftOk && rightOk) { checkAssignmentOperator(numberType); } } return numberType; case 35: - case 56: + case 57: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -18252,7 +18696,7 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 56) { + if (operator === 57) { checkAssignmentOperator(resultType); } return resultType; @@ -18271,23 +18715,23 @@ var ts; reportOperatorError(); } return booleanType; - case 89: - return checkInstanceOfExpression(node, leftType, rightType); - case 88: - return checkInExpression(node, leftType, rightType); - case 50: - return rightType; + case 91: + return checkInstanceOfExpression(left, right, leftType, rightType); + case 90: + return checkInExpression(left, right, leftType, rightType); case 51: + return rightType; + case 52: return getUnionType([leftType, rightType]); - case 55: + case 56: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); case 24: return rightType; } function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? node.left : - someConstituentTypeHasKind(rightType, 16777216) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? left : + someConstituentTypeHasKind(rightType, 16777216) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -18297,29 +18741,29 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 46: - case 65: - return 51; case 47: - case 66: + case 67: + return 52; + case 48: + case 68: return 33; - case 45: - case 64: - return 50; + case 46: + case 66: + return 51; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 55 && operator <= 66) { - 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 (produceDiagnostics && operator >= 56 && operator <= 68) { + var ok = checkReferenceExpression(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); + checkTypeAssignableTo(valueType, leftType, left, undefined); } } } function reportOperatorError() { - error(node, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(node.operatorToken.kind), typeToString(leftType), typeToString(rightType)); + error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); } } function isYieldExpressionInClass(node) { @@ -18395,14 +18839,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 134) { + if (node.name.kind === 136) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 134) { + if (node.name.kind === 136) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -18425,7 +18869,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 133) { + if (node.kind === 135) { type = checkQualifiedName(node); } else { @@ -18433,9 +18877,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 164 && node.parent.expression === node) || - (node.parent.kind === 165 && node.parent.expression === node) || - ((node.kind === 67 || node.kind === 133) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 166 && node.parent.expression === node) || + (node.parent.kind === 167 && node.parent.expression === node) || + ((node.kind === 69 || node.kind === 135) && 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); } @@ -18448,78 +18892,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 67: + case 69: return checkIdentifier(node); - case 95: + case 97: return checkThisExpression(node); - case 93: + case 95: return checkSuperExpression(node); - case 91: + case 93: return nullType; - case 97: - case 82: + case 99: + case 84: return booleanType; case 8: return checkNumericLiteral(node); - case 181: + case 183: return checkTemplateExpression(node); case 9: case 11: return stringType; case 10: return globalRegExpType; - case 162: - return checkArrayLiteral(node, contextualMapper); - case 163: - return checkObjectLiteral(node, contextualMapper); case 164: - return checkPropertyAccessExpression(node); + return checkArrayLiteral(node, contextualMapper); case 165: - return checkIndexedAccess(node); + return checkObjectLiteral(node, contextualMapper); case 166: + return checkPropertyAccessExpression(node); case 167: - return checkCallExpression(node); + return checkIndexedAccess(node); case 168: - return checkTaggedTemplateExpression(node); + case 169: + return checkCallExpression(node); case 170: + return checkTaggedTemplateExpression(node); + case 172: return checkExpression(node.expression, contextualMapper); - case 184: + case 186: return checkClassExpression(node); - case 171: - case 172: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 173: case 174: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 176: return checkTypeOfExpression(node); - case 169: - case 187: + case 171: + case 189: return checkAssertion(node); - case 173: - return checkDeleteExpression(node); case 175: + return checkDeleteExpression(node); + case 177: return checkVoidExpression(node); - case 176: + case 178: return checkAwaitExpression(node); - case 177: + case 179: return checkPrefixUnaryExpression(node); - case 178: + case 180: return checkPostfixUnaryExpression(node); - case 179: + case 181: return checkBinaryExpression(node, contextualMapper); - case 180: + case 182: return checkConditionalExpression(node, contextualMapper); - case 183: - return checkSpreadElementExpression(node, contextualMapper); case 185: + return checkSpreadElementExpression(node, contextualMapper); + case 187: return undefinedType; - case 182: + case 184: return checkYieldExpression(node); - case 238: + case 240: return checkJsxExpression(node); - case 231: + case 233: return checkJsxElement(node); - case 232: + case 234: return checkJsxSelfClosingElement(node); - case 233: + case 235: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -18540,7 +18984,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 142 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 144 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -18555,15 +18999,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 141 || - node.kind === 211 || - node.kind === 171; + return node.kind === 143 || + node.kind === 213 || + node.kind === 173; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 67 && + if (param.name.kind === 69 && param.name.text === parameter.text) { return i; } @@ -18573,30 +19017,30 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { - case 172: - case 145: - case 211: - case 171: - case 150: - case 141: - case 140: + case 174: + case 147: + case 213: + case 173: + case 152: + case 143: + case 142: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { - if (node.kind === 147) { + if (node.kind === 149) { checkGrammarIndexSignature(node); } - else if (node.kind === 150 || node.kind === 211 || node.kind === 151 || - node.kind === 145 || node.kind === 142 || - node.kind === 146) { + else if (node.kind === 152 || node.kind === 213 || node.kind === 153 || + node.kind === 147 || node.kind === 144 || + node.kind === 148) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 148) { + if (node.type.kind === 150) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -18615,19 +19059,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 159 || - param.name.kind === 160) { + if (param.name.kind === 161 || + param.name.kind === 162) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 67 && + if (element.name.kind === 69 && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 160 || - element.name.kind === 159) { + else if (element.name.kind === 162 || + element.name.kind === 161) { checkBindingPattern(element.name); } } @@ -18651,10 +19095,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 146: + case 148: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 145: + case 147: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -18676,7 +19120,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 213) { + if (node.kind === 215) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -18691,7 +19135,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 128: + case 130: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -18699,7 +19143,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 126: + case 128: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -18739,7 +19183,7 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 166 && n.expression.kind === 93; + return n.kind === 168 && n.expression.kind === 95; } function containsSuperCallAsComputedPropertyName(n) { return n.name && containsSuperCall(n.name); @@ -18757,15 +19201,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 95) { + if (n.kind === 97) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 171 && n.kind !== 211) { + else if (n.kind !== 173 && n.kind !== 213) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 139 && + return n.kind === 141 && !(n.flags & 128) && !!n.initializer; } @@ -18785,7 +19229,7 @@ var ts; var superCallStatement; for (var _i = 0; _i < statements.length; _i++) { var statement = statements[_i]; - if (statement.kind === 193 && isSuperCallExpression(statement.expression)) { + if (statement.kind === 195 && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; } @@ -18809,13 +19253,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 143) { + if (node.kind === 145) { 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 === 143 ? 144 : 143; + var otherKind = node.kind === 145 ? 146 : 145; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -18900,9 +19344,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213) { - ts.Debug.assert(signatureDeclarationNode.kind === 145 || signatureDeclarationNode.kind === 146); - var signatureKind = signatureDeclarationNode.kind === 145 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 215) { + ts.Debug.assert(signatureDeclarationNode.kind === 147 || signatureDeclarationNode.kind === 148); + var signatureKind = signatureDeclarationNode.kind === 147 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -18920,7 +19364,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 213 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 215 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -18996,7 +19440,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 141 || node.kind === 140); + ts.Debug.assert(node.kind === 143 || node.kind === 142); 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_1, diagnostic); @@ -19028,11 +19472,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 213 || node.parent.kind === 153 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 215 || node.parent.kind === 155 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 211 || node.kind === 141 || node.kind === 140 || node.kind === 142) { + if (node.kind === 213 || node.kind === 143 || node.kind === 142 || node.kind === 144) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -19145,16 +19589,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 213: + case 215: return 2097152; - case 216: + case 218: return d.name.kind === 9 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 212: - case 215: + case 214: + case 217: return 2097152 | 1048576; - case 219: + case 221: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -19165,7 +19609,8 @@ var ts; } } function checkNonThenableType(type, location, message) { - if (!(type.flags & 1) && isTypeAssignableTo(type, getGlobalThenableType())) { + type = getWidenedType(type); + if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -19280,22 +19725,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 212: + case 214: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 136: + case 138: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 139: + case 141: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 141: case 143: - case 144: + case 145: + case 146: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -19304,9 +19749,9 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 149) { + if (node && node.kind === 151) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 149 ? 793056 : 1536; + var meaning = root.parent.kind === 151 ? 793056 : 1536; var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); if (rootSymbol && rootSymbol.flags & 8388608) { var aliasTarget = resolveAlias(rootSymbol); @@ -19318,19 +19763,19 @@ var ts; } function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 139: + case 141: checkTypeNodeAsExpression(node.type); break; - case 136: + case 138: checkTypeNodeAsExpression(node.type); break; - case 141: + case 143: checkTypeNodeAsExpression(node.type); break; - case 143: + case 145: checkTypeNodeAsExpression(node.type); break; - case 144: + case 146: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -19353,24 +19798,24 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 212: + case 214: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 141: - checkParameterTypeAnnotationsAsExpressions(node); - case 144: case 143: - case 139: - case 136: + checkParameterTypeAnnotationsAsExpressions(node); + case 146: + case 145: + case 141: + case 138: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 136) { + if (node.kind === 138) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -19388,12 +19833,9 @@ var ts; checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { - if (!compilerOptions.experimentalAsyncFunctions) { - error(node, ts.Diagnostics.Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning); - } emitAwaiter = true; } - if (node.name && node.name.kind === 134) { + if (node.name && node.name.kind === 136) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -19428,11 +19870,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 190) { + if (node.kind === 192) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 217) { + if (ts.isFunctionBlock(node) || node.kind === 219) { checkFunctionAndClassExpressionBodies(node); } } @@ -19450,19 +19892,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 139 || - node.kind === 138 || - node.kind === 141 || + if (node.kind === 141 || node.kind === 140 || node.kind === 143 || - node.kind === 144) { + node.kind === 142 || + node.kind === 145 || + node.kind === 146) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 136 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 138 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -19476,7 +19918,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 67; + var isDeclaration_1 = node.kind !== 69; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -19497,7 +19939,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 67; + var isDeclaration_2 = node.kind !== 69; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -19510,11 +19952,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 216 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 218 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 246 && ts.isExternalModule(parent)) { + if (parent.kind === 248 && ts.isExternalOrCommonJsModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -19522,7 +19964,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 209 && !node.initializer) { + if (node.kind === 211 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -19532,15 +19974,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210); - var container = varDeclList.parent.kind === 191 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212); + var container = varDeclList.parent.kind === 193 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 190 && ts.isFunctionLike(container.parent) || - container.kind === 217 || - container.kind === 216 || - container.kind === 246); + (container.kind === 192 && ts.isFunctionLike(container.parent) || + container.kind === 219 || + container.kind === 218 || + container.kind === 248); if (!namesShareScope) { var name_15 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_15, name_15); @@ -19550,16 +19992,16 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 136) { + if (ts.getRootDeclaration(node).kind !== 138) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 67) { + if (n.kind === 69) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 136) { + if (referencedSymbol.valueDeclaration.kind === 138) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -19579,7 +20021,7 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 134) { + if (node.name.kind === 136) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -19588,7 +20030,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 136 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 138 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -19616,9 +20058,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 139 && node.kind !== 138) { + if (node.kind !== 141 && node.kind !== 140) { checkExportsOnMergedDeclarations(node); - if (node.kind === 209 || node.kind === 161) { + if (node.kind === 211 || node.kind === 163) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -19639,7 +20081,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 163) { + if (node.modifiers && node.parent.kind === 165) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -19672,12 +20114,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 210) { + if (node.initializer && node.initializer.kind === 212) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -19692,13 +20134,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 162 || varExpr.kind === 163) { + if (varExpr.kind === 164 || varExpr.kind === 165) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -19713,7 +20155,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { 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); @@ -19723,7 +20165,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 162 || varExpr.kind === 163) { + if (varExpr.kind === 164 || varExpr.kind === 165) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { @@ -19885,7 +20327,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144))); + return !!(node.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -19903,10 +20345,10 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 144) { + if (func.kind === 146) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 142) { + else if (func.kind === 144) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -19915,7 +20357,9 @@ var ts; if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - checkTypeAssignableTo(awaitedType, promisedType, node.expression); + if (promisedType) { + checkTypeAssignableTo(awaitedType, promisedType, node.expression); + } } else { checkTypeAssignableTo(exprType, returnType, node.expression); @@ -19939,7 +20383,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 240 && !hasDuplicateDefaultClause) { + if (clause.kind === 242 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -19951,7 +20395,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 239) { + if (produceDiagnostics && clause.kind === 241) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -19968,7 +20412,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 205 && current.label.text === node.label.text) { + if (current.kind === 207 && 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; @@ -19994,7 +20438,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 67) { + if (catchClause.variableDeclaration.name.kind !== 69) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -20062,7 +20506,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 134 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 136 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -20132,6 +20576,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { @@ -20150,7 +20595,7 @@ var ts; } } } - checkTypeAssignableTo(type, baseType, node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32)) { var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); @@ -20163,7 +20608,8 @@ var ts; } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { - ts.forEach(implementedTypeNodes, function (typeRefNode) { + for (var _b = 0; _b < implementedTypeNodes.length; _b++) { + var typeRefNode = implementedTypeNodes[_b]; if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } @@ -20173,14 +20619,14 @@ var ts; if (t !== unknownType) { var declaredType = (t.flags & 4096) ? t.target : t; if (declaredType.flags & (1024 | 2048)) { - checkTypeAssignableTo(type, t, node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { error(typeRefNode, ts.Diagnostics.A_class_may_only_implement_another_class_or_interface); } } } - }); + } } if (produceDiagnostics) { checkIndexConstraints(type); @@ -20208,7 +20654,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) { - if (derivedClassDecl.kind === 184) { + if (derivedClassDecl.kind === 186) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -20252,7 +20698,7 @@ var ts; } } function isAccessor(kind) { - return kind === 143 || kind === 144; + return kind === 145 || kind === 146; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -20289,7 +20735,7 @@ var ts; var ok = true; for (var _i = 0; _i < baseTypes.length; _i++) { var base = baseTypes[_i]; - var properties = getPropertiesOfObjectType(base); + var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); for (var _a = 0; _a < properties.length; _a++) { var prop = properties[_a]; if (!ts.hasProperty(seen, prop.name)) { @@ -20318,7 +20764,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 215); 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); @@ -20326,17 +20772,19 @@ var ts; } if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); if (checkInheritedPropertiesAreIdentical(type, node.name)) { - ts.forEach(getBaseTypes(type), function (baseType) { - checkTypeAssignableTo(type, baseType, node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); - }); + for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) { + var baseType = _a[_i]; + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); + } checkIndexConstraints(type); } } if (symbol && symbol.declarations) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 212 && !ts.isInAmbientContext(declaration)) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var declaration = _c[_b]; + if (declaration.kind === 214 && !ts.isInAmbientContext(declaration)) { error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } @@ -20367,10 +20815,15 @@ var ts; var autoValue = 0; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); - ts.forEach(node.members, function (member) { - if (member.name.kind !== 134 && isNumericLiteralName(member.name.text)) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.name.kind === 136) { + error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); + } + else if (isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } + var previousEnumMemberIsNonConstant = autoValue === undefined; var initializer = member.initializer; if (initializer) { autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); @@ -20378,10 +20831,13 @@ var ts; else if (ambient && !enumIsConst) { autoValue = undefined; } + else if (previousEnumMemberIsNonConstant) { + error(member.name, ts.Diagnostics.Enum_member_must_have_initializer); + } if (autoValue !== undefined) { getNodeLinks(member).enumMemberValue = autoValue++; } - }); + } nodeLinks.flags |= 8192; } function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { @@ -20392,7 +20848,10 @@ var ts; if (enumIsConst) { error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); } - else if (!ambient) { + else if (ambient) { + error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); + } + else { checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); } } @@ -20408,7 +20867,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 177: + case 179: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -20416,10 +20875,10 @@ var ts; switch (e.operator) { case 35: return value_1; case 36: return -value_1; - case 49: return ~value_1; + case 50: return ~value_1; } return undefined; - case 179: + case 181: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -20429,37 +20888,37 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 46: return left | right; - case 45: return left & right; - case 43: return left >> right; - case 44: return left >>> right; - case 42: return left << right; - case 47: return left ^ right; + case 47: return left | right; + case 46: return left & right; + case 44: return left >> right; + case 45: return left >>> right; + case 43: return left << right; + case 48: return left ^ right; case 37: return left * right; - case 38: return left / right; + case 39: return left / right; case 35: return left + right; case 36: return left - right; - case 39: return left % right; + case 40: return left % right; } return undefined; case 8: return +e.text; - case 170: + case 172: return evalConstant(e.expression); - case 67: - case 165: - case 164: + case 69: + case 167: + case 166: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName; - if (e.kind === 67) { + if (e.kind === 69) { enumType_1 = currentType; propertyName = e.text; } else { var expression; - if (e.kind === 165) { + if (e.kind === 167) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -20473,10 +20932,10 @@ var ts; } var current = expression; while (current) { - if (current.kind === 67) { + if (current.kind === 69) { break; } - else if (current.kind === 164) { + else if (current.kind === 166) { current = current.expression; } else { @@ -20499,7 +20958,7 @@ var ts; if (member === propertyDecl) { return undefined; } - if (!isDefinedBefore(propertyDecl, member)) { + if (!isBlockScopedNameDeclaredBeforeUse(propertyDecl, member)) { reportError = false; error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; @@ -20513,7 +20972,7 @@ var ts; if (!produceDiagnostics) { return; } - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -20535,7 +20994,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 215) { + if (declaration.kind !== 217) { return false; } var enumDeclaration = declaration; @@ -20558,8 +21017,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 212 || - (declaration.kind === 211 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 214 || + (declaration.kind === 213 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -20610,7 +21069,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 212); + var mergedClass = ts.getDeclarationOfKind(symbol, 214); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -20618,9 +21077,9 @@ var ts; } if (isAmbientExternalModule) { if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); } - if (isExternalModuleNameRelative(node.name.text)) { + if (ts.isExternalModuleNameRelative(node.name.text)) { error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); } } @@ -20629,17 +21088,17 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 133) { + if (node.kind === 135) { node = node.left; } - else if (node.kind === 164) { + else if (node.kind === 166) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 67); + ts.Debug.assert(node.kind === 69); return node; } function checkExternalImportOrExportDeclaration(node) { @@ -20648,14 +21107,14 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; - if (node.parent.kind !== 246 && !inAmbientExternalModule) { - error(moduleName, node.kind === 226 ? + var inAmbientExternalModule = node.parent.kind === 219 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 248 && !inAmbientExternalModule) { + error(moduleName, node.kind === 228 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; } - if (inAmbientExternalModule && isExternalModuleNameRelative(moduleName.text)) { + if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); return false; } @@ -20669,7 +21128,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 228 ? + var message = node.kind === 230 ? 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)); @@ -20695,7 +21154,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222) { + if (importClause.namedBindings.kind === 224) { checkImportBinding(importClause.namedBindings); } else { @@ -20730,8 +21189,8 @@ var ts; } } else { - if (languageVersion >= 2 && !ts.isInAmbientContext(node)) { - 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); + if (modulekind === 5 && !ts.isInAmbientContext(node)) { + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } } @@ -20746,8 +21205,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; - if (node.parent.kind !== 246 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 219 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 248 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -20760,7 +21219,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 246 && node.parent.kind !== 217 && node.parent.kind !== 216) { + if (node.parent.kind !== 248 && node.parent.kind !== 219 && node.parent.kind !== 218) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -20774,15 +21233,15 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 246 ? node.parent : node.parent.parent; - if (container.kind === 216 && container.name.kind === 67) { + var container = node.parent.kind === 248 ? node.parent : node.parent.parent; + if (container.kind === 218 && container.name.kind === 69) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 67) { + if (node.expression.kind === 69) { markExportAsReferenced(node); } else { @@ -20790,19 +21249,19 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (languageVersion >= 2) { - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + if (modulekind === 5) { + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); } - else if (compilerOptions.module === 4) { + else if (modulekind === 4) { grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); } } } function getModuleStatements(node) { - if (node.kind === 246) { + if (node.kind === 248) { return node.statements; } - if (node.kind === 216 && node.body.kind === 217) { + if (node.kind === 218 && node.body.kind === 219) { return node.body.statements; } return emptyArray; @@ -20839,183 +21298,182 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 216: - case 212: + case 218: + case 214: + case 215: case 213: - case 211: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 135: + case 137: return checkTypeParameter(node); - case 136: - return checkParameter(node); - case 139: case 138: + return checkParameter(node); + case 141: + case 140: return checkPropertyDeclaration(node); - case 150: - case 151: - case 145: - case 146: - return checkSignatureDeclaration(node); + case 152: + case 153: case 147: + case 148: + return checkSignatureDeclaration(node); + case 149: return checkSignatureDeclaration(node); - case 141: - case 140: - return checkMethodDeclaration(node); - case 142: - return checkConstructorDeclaration(node); case 143: + case 142: + return checkMethodDeclaration(node); case 144: + return checkConstructorDeclaration(node); + case 145: + case 146: return checkAccessorDeclaration(node); - case 149: + case 151: return checkTypeReferenceNode(node); - case 148: + case 150: return checkTypePredicate(node); - case 152: - return checkTypeQuery(node); - case 153: - return checkTypeLiteral(node); case 154: - return checkArrayType(node); + return checkTypeQuery(node); case 155: - return checkTupleType(node); + return checkTypeLiteral(node); case 156: + return checkArrayType(node); case 157: - return checkUnionOrIntersectionType(node); + return checkTupleType(node); case 158: + case 159: + return checkUnionOrIntersectionType(node); + case 160: return checkSourceElement(node.type); - case 211: + case 213: return checkFunctionDeclaration(node); - case 190: - case 217: + case 192: + case 219: return checkBlock(node); - case 191: - return checkVariableStatement(node); case 193: - return checkExpressionStatement(node); - case 194: - return checkIfStatement(node); + return checkVariableStatement(node); case 195: - return checkDoStatement(node); + return checkExpressionStatement(node); case 196: - return checkWhileStatement(node); + return checkIfStatement(node); case 197: - return checkForStatement(node); + return checkDoStatement(node); case 198: - return checkForInStatement(node); + return checkWhileStatement(node); case 199: - return checkForOfStatement(node); + return checkForStatement(node); case 200: + return checkForInStatement(node); case 201: - return checkBreakOrContinueStatement(node); + return checkForOfStatement(node); case 202: - return checkReturnStatement(node); case 203: - return checkWithStatement(node); + return checkBreakOrContinueStatement(node); case 204: - return checkSwitchStatement(node); + return checkReturnStatement(node); case 205: - return checkLabeledStatement(node); + return checkWithStatement(node); case 206: - return checkThrowStatement(node); + return checkSwitchStatement(node); case 207: - return checkTryStatement(node); + return checkLabeledStatement(node); + case 208: + return checkThrowStatement(node); case 209: + return checkTryStatement(node); + case 211: return checkVariableDeclaration(node); - case 161: + case 163: return checkBindingElement(node); - case 212: + case 214: return checkClassDeclaration(node); - case 213: + case 215: return checkInterfaceDeclaration(node); - case 214: + case 216: return checkTypeAliasDeclaration(node); - case 215: + case 217: return checkEnumDeclaration(node); - case 216: + case 218: return checkModuleDeclaration(node); - case 220: + case 222: return checkImportDeclaration(node); - case 219: + case 221: return checkImportEqualsDeclaration(node); - case 226: + case 228: return checkExportDeclaration(node); - case 225: + case 227: return checkExportAssignment(node); - case 192: + case 194: checkGrammarStatementInAmbientContext(node); return; - case 208: + case 210: checkGrammarStatementInAmbientContext(node); return; - case 229: + case 231: return checkMissingDeclaration(node); } } function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 171: - case 172: + case 173: + case 174: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 184: + case 186: ts.forEach(node.members, checkSourceElement); + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; - case 141: - case 140: + case 143: + case 142: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 142: - case 143: case 144: - case 211: + case 145: + case 146: + case 213: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 203: + case 205: checkFunctionAndClassExpressionBodies(node.expression); break; - case 137: - case 136: case 139: case 138: - case 159: - case 160: + case 141: + case 140: case 161: case 162: case 163: - case 243: case 164: case 165: + case 245: case 166: case 167: case 168: - case 181: - case 188: case 169: - case 187: case 170: - case 174: - case 175: + case 183: + case 190: + case 171: + case 189: + case 172: case 176: - case 173: case 177: case 178: + case 175: case 179: case 180: - case 183: + case 181: case 182: - case 190: - case 217: - case 191: + case 185: + case 184: + case 192: + case 219: case 193: - case 194: case 195: case 196: case 197: @@ -21024,29 +21482,31 @@ var ts; case 200: case 201: case 202: + case 203: case 204: - case 218: - case 239: - case 240: - case 205: case 206: - case 207: + case 220: + case 241: case 242: + case 207: + case 208: case 209: - case 210: + case 244: + case 211: case 212: - case 241: - case 186: - case 215: - case 245: - case 225: - case 246: - case 238: - case 231: - case 232: - case 236: - case 237: + case 214: + case 243: + case 188: + case 217: + case 247: + case 227: + case 248: + case 240: case 233: + case 234: + case 238: + case 239: + case 235: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -21069,7 +21529,7 @@ var ts; potentialThisCollisions.length = 0; ts.forEach(node.statements, checkSourceElement); checkFunctionAndClassExpressionBodies(node); - if (ts.isExternalModule(node)) { + if (ts.isExternalOrCommonJsModule(node)) { checkExternalModuleExports(node); } if (potentialThisCollisions.length) { @@ -21124,7 +21584,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 203 && node.parent.statement === node) { + if (node.parent.kind === 205 && node.parent.statement === node) { return true; } node = node.parent; @@ -21146,28 +21606,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 246: - if (!ts.isExternalModule(location)) { + case 248: + if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 216: + case 218: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 215: + case 217: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 184: + case 186: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 212: - case 213: + case 214: + case 215: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 171: + case 173: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -21200,42 +21660,42 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 67 && + return name.kind === 69 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 135: - case 212: - case 213: + case 137: case 214: case 215: + case 216: + case 217: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 133) { + while (node.parent && node.parent.kind === 135) { node = node.parent; } - return node.parent && node.parent.kind === 149; + return node.parent && node.parent.kind === 151; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 164) { + while (node.parent && node.parent.kind === 166) { node = node.parent; } - return node.parent && node.parent.kind === 186; + return node.parent && node.parent.kind === 188; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 133) { + while (nodeOnRightSide.parent.kind === 135) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 219) { + if (nodeOnRightSide.parent.kind === 221) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 225) { + if (nodeOnRightSide.parent.kind === 227) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -21247,10 +21707,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 225) { + if (entityName.parent.kind === 227) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 164) { + if (entityName.kind !== 166) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -21259,31 +21719,40 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 186 ? 793056 : 1536; + var meaning = 0; + if (entityName.parent.kind === 188) { + meaning = 793056; + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + meaning |= 107455; + } + } + else { + meaning = 1536; + } meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 233) || - (entityName.parent.kind === 232) || - (entityName.parent.kind === 235)) { + else if ((entityName.parent.kind === 235) || + (entityName.parent.kind === 234) || + (entityName.parent.kind === 237)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 67) { + if (entityName.kind === 69) { var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 164) { + else if (entityName.kind === 166) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 133) { + else if (entityName.kind === 135) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -21292,14 +21761,14 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 149 ? 793056 : 1536; + var meaning = entityName.parent.kind === 151 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 236) { + else if (entityName.parent.kind === 238) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 148) { + if (entityName.parent.kind === 150) { return resolveEntityName(entityName, 1); } return undefined; @@ -21311,14 +21780,14 @@ var ts; if (ts.isDeclarationName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 67) { + if (node.kind === 69) { if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 225 + return node.parent.kind === 227 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } - else if (node.parent.kind === 161 && - node.parent.parent.kind === 159 && + else if (node.parent.kind === 163 && + node.parent.parent.kind === 161 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -21328,29 +21797,29 @@ var ts; } } switch (node.kind) { - case 67: - case 164: - case 133: + case 69: + case 166: + case 135: return getSymbolOfEntityNameOrPropertyAccessExpression(node); + case 97: case 95: - case 93: - var type = checkExpression(node); + var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 119: + case 121: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 142) { + if (constructorDeclaration && constructorDeclaration.kind === 144) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 220 || node.parent.kind === 226) && + ((node.parent.kind === 222 || node.parent.kind === 228) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 165 && node.parent.argumentExpression === node) { + if (node.parent.kind === 167 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -21364,7 +21833,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 244) { + if (location && location.kind === 246) { return resolveEntityName(location.name, 107455); } return undefined; @@ -21464,11 +21933,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 246) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 248) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 216 || n.kind === 215) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 218 || n.kind === 217) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -21481,11 +21950,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 190: - case 218: - case 197: - case 198: + case 192: + case 220: case 199: + case 200: + case 201: return true; } return false; @@ -21511,22 +21980,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 219: case 221: - case 222: + case 223: case 224: - case 228: - return isAliasResolvedToValue(getSymbolOfNode(node)); case 226: + case 230: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case 228: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 225: - return node.expression && node.expression.kind === 67 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 227: + return node.expression && node.expression.kind === 69 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 246 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 248 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -21574,7 +22043,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 245) { + if (node.kind === 247) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -21660,21 +22129,6 @@ var ts; var symbol = getReferencedValueSymbol(reference); return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; } - function getBlockScopedVariableId(n) { - ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 161 || (n.parent.kind === 209 && 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 !== 242; - if (isLetOrConst) { - getSymbolLinks(symbol); - return symbol.id; - } - return undefined; - } function instantiateSingleCallFunctionType(functionType, typeArguments) { if (functionType === unknownType) { return unknownType; @@ -21706,7 +22160,6 @@ var ts; isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, collectLinkedAliases: collectLinkedAliases, - getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, isOptionalParameter: isOptionalParameter @@ -21717,7 +22170,7 @@ var ts; ts.bindSourceFile(file); }); ts.forEach(host.getSourceFiles(), function (file) { - if (!ts.isExternalModule(file)) { + if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } }); @@ -21745,6 +22198,7 @@ var ts; getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); getGlobalThenableType = ts.memoize(createThenableType); + cjsRequireType = getExportedTypeFromNamespace("CommonJS", "Require"); if (languageVersion >= 2) { globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); @@ -21787,10 +22241,7 @@ var ts; if (!ts.nodeCanBeDecorated(node)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } - else if (languageVersion < 1) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (node.kind === 143 || node.kind === 144) { + else if (node.kind === 145 || node.kind === 146) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -21800,38 +22251,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 143: + case 145: + case 146: case 144: - case 142: - case 139: - case 138: case 141: case 140: - case 147: - case 216: - case 220: - case 219: - case 226: - case 225: - case 136: + case 143: + case 142: + case 149: + case 218: + case 222: + case 221: + case 228: + case 227: + case 138: break; - case 211: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116) && - node.parent.kind !== 217 && node.parent.kind !== 246) { + case 213: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118) && + node.parent.kind !== 219 && node.parent.kind !== 248) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 212: - case 213: - case 191: case 214: - if (node.modifiers && node.parent.kind !== 217 && node.parent.kind !== 246) { + case 215: + case 193: + case 216: + if (node.modifiers && node.parent.kind !== 219 && node.parent.kind !== 248) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 215: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72) && - node.parent.kind !== 217 && node.parent.kind !== 246) { + case 217: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74) && + node.parent.kind !== 219 && node.parent.kind !== 248) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -21846,14 +22297,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { + case 112: + case 111: case 110: - case 109: - case 108: var text = void 0; - if (modifier.kind === 110) { + if (modifier.kind === 112) { text = "public"; } - else if (modifier.kind === 109) { + else if (modifier.kind === 111) { text = "protected"; lastProtected = modifier; } @@ -21870,11 +22321,11 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 217 || node.parent.kind === 246) { + else if (node.parent.kind === 219 || node.parent.kind === 248) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256) { - if (modifier.kind === 108) { + if (modifier.kind === 110) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -21883,17 +22334,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 111: + case 113: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 217 || node.parent.kind === 246) { + else if (node.parent.kind === 219 || node.parent.kind === 248) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256) { @@ -21902,7 +22353,7 @@ var ts; flags |= 128; lastStatic = modifier; break; - case 80: + case 82: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -21915,42 +22366,42 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 214) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 120: + case 122: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 214) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 113: + case 115: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 212) { - if (node.kind !== 141) { + if (node.kind !== 214) { + if (node.kind !== 143) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 212 && node.parent.flags & 256)) { + if (!(node.parent.kind === 214 && node.parent.flags & 256)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128) { @@ -21962,14 +22413,14 @@ var ts; } flags |= 256; break; - case 116: + case 118: if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512; @@ -21977,7 +22428,7 @@ var ts; break; } } - if (node.kind === 142) { + if (node.kind === 144) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -21995,10 +22446,10 @@ var ts; } return; } - else if ((node.kind === 220 || node.kind === 219) && flags & 2) { + else if ((node.kind === 222 || node.kind === 221) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 136 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 138 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512) { @@ -22010,10 +22461,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 141: - case 211: - case 171: - case 172: + case 143: + case 213: + case 173: + case 174: if (!node.asteriskToken) { return false; } @@ -22078,7 +22529,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 172) { + if (node.kind === 174) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -22113,7 +22564,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 !== 128 && parameter.type.kind !== 126) { + if (parameter.type.kind !== 130 && parameter.type.kind !== 128) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -22145,7 +22596,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 185) { + if (arg.kind === 187) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -22172,7 +22623,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 81) { + if (heritageClause.token === 83) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -22185,7 +22636,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 104); + ts.Debug.assert(heritageClause.token === 106); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -22200,14 +22651,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 81) { + if (heritageClause.token === 83) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 104); + ts.Debug.assert(heritageClause.token === 106); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -22216,19 +22667,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 134) { + if (node.kind !== 136) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 179 && computedPropertyName.expression.operatorToken.kind === 24) { + if (computedPropertyName.expression.kind === 181 && computedPropertyName.expression.operatorToken.kind === 24) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 211 || - node.kind === 171 || - node.kind === 141); + ts.Debug.assert(node.kind === 213 || + node.kind === 173 || + node.kind === 143); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -22245,7 +22696,7 @@ var ts; return grammarErrorOnNode(questionToken, message); } } - function checkGrammarObjectLiteralExpression(node) { + function checkGrammarObjectLiteralExpression(node, inDestructuring) { var seen = {}; var Property = 1; var GetAccessor = 2; @@ -22254,26 +22705,29 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_17 = prop.name; - if (prop.kind === 185 || - name_17.kind === 134) { + if (prop.kind === 187 || + name_17.kind === 136) { checkGrammarComputedPropertyName(name_17); continue; } + if (prop.kind === 246 && !inDestructuring && prop.objectAssignmentInitializer) { + return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); + } var currentKind = void 0; - if (prop.kind === 243 || prop.kind === 244) { + if (prop.kind === 245 || prop.kind === 246) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_17.kind === 8) { checkGrammarNumericLiteral(name_17); } currentKind = Property; } - else if (prop.kind === 141) { + else if (prop.kind === 143) { currentKind = Property; } - else if (prop.kind === 143) { + else if (prop.kind === 145) { currentKind = GetAccessor; } - else if (prop.kind === 144) { + else if (prop.kind === 146) { currentKind = SetAccesor; } else { @@ -22305,7 +22759,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 237) { + if (attr.kind === 239) { continue; } var jsxAttr = attr; @@ -22317,7 +22771,7 @@ var ts; return grammarErrorOnNode(name_18, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 238 && !initializer.expression) { + if (initializer && initializer.kind === 240 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -22326,24 +22780,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 210) { + if (forInOrOfStatement.initializer.kind === 212) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 198 + var diagnostic = forInOrOfStatement.kind === 200 ? 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 === 198 + var diagnostic = forInOrOfStatement.kind === 200 ? 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 = forInOrOfStatement.kind === 198 + var diagnostic = forInOrOfStatement.kind === 200 ? 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); @@ -22366,10 +22820,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 143 && accessor.parameters.length) { + else if (kind === 145 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 144) { + else if (kind === 146) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -22394,7 +22848,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 134 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 136 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -22404,7 +22858,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 163) { + if (node.parent.kind === 165) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -22423,22 +22877,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 === 213) { + else if (node.parent.kind === 215) { 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 === 153) { + else if (node.parent.kind === 155) { 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 199: + case 200: + case 201: case 197: case 198: - case 199: - case 195: - case 196: return true; - case 205: + case 207: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -22450,9 +22904,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 205: + case 207: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 200 + var isMisplacedContinueLabel = node.kind === 202 && !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); @@ -22460,8 +22914,8 @@ var ts; return false; } break; - case 204: - if (node.kind === 201 && !node.label) { + case 206: + if (node.kind === 203 && !node.label) { return false; } break; @@ -22474,13 +22928,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 201 + var message = node.kind === 203 ? 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 === 201 + var message = node.kind === 203 ? 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); @@ -22492,7 +22946,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 160 || node.name.kind === 159) { + if (node.name.kind === 162 || node.name.kind === 161) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -22501,7 +22955,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 198 && node.parent.parent.kind !== 199) { + if (node.parent.parent.kind !== 200 && node.parent.parent.kind !== 201) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -22521,7 +22975,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 67) { + if (name.kind === 69) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -22530,7 +22984,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 185) { + if (element.kind !== 187) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -22547,15 +23001,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 194: - case 195: case 196: - case 203: case 197: case 198: + case 205: case 199: + case 200: + case 201: return false; - case 205: + case 207: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -22571,7 +23025,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 177) { + if (expression.kind === 179) { var unaryExpression = expression; if (unaryExpression.operator === 35 || unaryExpression.operator === 36) { expression = unaryExpression.operand; @@ -22582,32 +23036,6 @@ var ts; } return false; } - function checkGrammarEnumDeclaration(enumDecl) { - var enumIsConst = (enumDecl.flags & 32768) !== 0; - var hasError = false; - if (!enumIsConst) { - var inConstantEnumMemberSection = true; - var inAmbientContext = ts.isInAmbientContext(enumDecl); - for (var _i = 0, _a = enumDecl.members; _i < _a.length; _i++) { - var node = _a[_i]; - if (node.name.kind === 134) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); - } - else if (inAmbientContext) { - if (node.initializer && !isIntegerLiteral(node.initializer)) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers) || hasError; - } - } - else if (node.initializer) { - inConstantEnumMemberSection = isIntegerLiteral(node.initializer); - } - else if (!inConstantEnumMemberSection) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Enum_member_must_have_initializer) || hasError; - } - } - } - return hasError; - } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -22633,7 +23061,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 67 && + return node.kind === 69 && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -22653,12 +23081,12 @@ var ts; return true; } } - else if (node.parent.kind === 213) { + else if (node.parent.kind === 215) { 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 === 153) { + else if (node.parent.kind === 155) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -22668,11 +23096,11 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 213 || - node.kind === 220 || - node.kind === 219 || - node.kind === 226 || - node.kind === 225 || + if (node.kind === 215 || + node.kind === 222 || + node.kind === 221 || + node.kind === 228 || + node.kind === 227 || (node.flags & 2) || (node.flags & (1 | 1024))) { return false; @@ -22682,7 +23110,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 191) { + if (ts.isDeclaration(decl) || decl.kind === 193) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -22701,7 +23129,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 === 190 || node.parent.kind === 217 || node.parent.kind === 246) { + if (node.parent.kind === 192 || node.parent.kind === 219 || node.parent.kind === 248) { 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); @@ -22748,6 +23176,7 @@ var ts; var enclosingDeclaration; var currentSourceFile; var reportedDeclarationError = false; + var errorNameNode; var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var moduleElementDeclarationEmitInfo = []; @@ -22773,7 +23202,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 220); + ts.Debug.assert(aliasEmitInfo.node.kind === 222); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -22824,6 +23253,7 @@ var ts; function createAndSetNewTextWriterWithSymbolWriter() { var writer = ts.createTextWriter(newLine); writer.trackSymbol = trackSymbol; + writer.reportInaccessibleThisError = reportInaccessibleThisError; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -22846,10 +23276,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 209) { + if (declaration.kind === 211) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 223 || declaration.kind === 224 || declaration.kind === 221) { + else if (declaration.kind === 225 || declaration.kind === 226 || declaration.kind === 223) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -22860,7 +23290,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 220) { + if (moduleElementEmitInfo.node.kind === 222) { moduleElementEmitInfo.isVisible = true; } else { @@ -22868,12 +23298,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 216) { + if (nodeToCheck.kind === 218) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 216) { + if (nodeToCheck.kind === 218) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -22905,6 +23335,11 @@ var ts; function trackSymbol(symbol, enclosingDeclaration, meaning) { handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); } + function reportInaccessibleThisError() { + if (errorNameNode) { + diagnostics.push(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode))); + } + } function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); @@ -22912,7 +23347,9 @@ var ts; emitType(type); } else { + errorNameNode = declaration.name; resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2, writer); + errorNameNode = undefined; } } function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { @@ -22922,7 +23359,9 @@ var ts; emitType(signature.type); } else { + errorNameNode = signature.name; resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2, writer); + errorNameNode = undefined; } } function emitLines(nodes) { @@ -22960,62 +23399,63 @@ var ts; } function emitType(type) { switch (type.kind) { - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: - case 101: + case 120: + case 131: + case 103: + case 97: case 9: return writeTextOfNode(currentSourceFile, type); - case 186: + case 188: return emitExpressionWithTypeArguments(type); - case 149: + case 151: return emitTypeReference(type); - case 152: - return emitTypeQuery(type); case 154: + return emitTypeQuery(type); + case 156: return emitArrayType(type); - case 155: + case 157: return emitTupleType(type); - case 156: + case 158: return emitUnionType(type); - case 157: + case 159: return emitIntersectionType(type); - case 158: + case 160: return emitParenType(type); - case 150: - case 151: - return emitSignatureDeclarationWithJsDocComments(type); + case 152: case 153: + return emitSignatureDeclarationWithJsDocComments(type); + case 155: return emitTypeLiteral(type); - case 67: + case 69: return emitEntityName(type); - case 133: + case 135: return emitEntityName(type); - case 148: + case 150: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 67) { + if (entityName.kind === 69) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 133 ? entityName.left : entityName.expression; - var right = entityName.kind === 133 ? entityName.right : entityName.name; + var left = entityName.kind === 135 ? entityName.left : entityName.expression; + var right = entityName.kind === 135 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 219 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 221 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 67 || node.expression.kind === 164); + ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 166); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -23091,7 +23531,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 67) { + if (node.expression.kind === 69) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -23109,7 +23549,7 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 67) { + if (node.expression.kind === 69) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } @@ -23127,10 +23567,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 219 || - (node.parent.kind === 246 && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 221 || + (node.parent.kind === 248 && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 248) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -23139,7 +23579,7 @@ var ts; }); } else { - if (node.kind === 220) { + if (node.kind === 222) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -23157,23 +23597,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 211: + case 213: return writeFunctionDeclaration(node); - case 191: + case 193: return writeVariableStatement(node); - case 213: + case 215: return writeInterfaceDeclaration(node); - case 212: - return writeClassDeclaration(node); case 214: + return writeClassDeclaration(node); + case 216: return writeTypeAliasDeclaration(node); - case 215: + case 217: return writeEnumDeclaration(node); - case 216: + case 218: return writeModuleDeclaration(node); - case 219: + case 221: return writeImportEqualsDeclaration(node); - case 220: + case 222: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -23187,7 +23627,7 @@ var ts; if (node.flags & 1024) { write("default "); } - else if (node.kind !== 213) { + else if (node.kind !== 215) { write("declare "); } } @@ -23234,7 +23674,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 222) { + if (namedBindings.kind === 224) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -23260,7 +23700,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 222) { + if (node.importClause.namedBindings.kind === 224) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -23316,7 +23756,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 217) { + while (node.body.kind !== 219) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -23381,7 +23821,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 141 && (node.parent.flags & 32); + return node.parent.kind === 143 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -23391,15 +23831,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 150 || - node.parent.kind === 151 || - (node.parent.parent && node.parent.parent.kind === 153)) { - ts.Debug.assert(node.parent.kind === 141 || - node.parent.kind === 140 || - node.parent.kind === 150 || - node.parent.kind === 151 || - node.parent.kind === 145 || - node.parent.kind === 146); + if (node.parent.kind === 152 || + node.parent.kind === 153 || + (node.parent.parent && node.parent.parent.kind === 155)) { + ts.Debug.assert(node.parent.kind === 143 || + node.parent.kind === 142 || + node.parent.kind === 152 || + node.parent.kind === 153 || + node.parent.kind === 147 || + node.parent.kind === 148); emitType(node.constraint); } else { @@ -23409,31 +23849,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 212: + case 214: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 213: + case 215: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 146: + case 148: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 145: + case 147: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 141: - case 140: + case 143: + case 142: 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 === 212) { + else if (node.parent.parent.kind === 214) { 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 211: + case 213: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -23461,12 +23901,12 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 91) { + else if (!isImplementsList && node.expression.kind === 93) { write("null"); } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 212) { + if (node.parent.parent.kind === 214) { 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; @@ -23546,16 +23986,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 209 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 211 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 139 || node.kind === 138) && ts.hasQuestionToken(node)) { + if ((node.kind === 141 || node.kind === 140) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 139 || node.kind === 138) && node.parent.kind === 153) { + if ((node.kind === 141 || node.kind === 140) && node.parent.kind === 155) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32)) { @@ -23564,14 +24004,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 209) { + if (node.kind === 211) { 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 === 139 || node.kind === 138) { + else if (node.kind === 141 || node.kind === 140) { if (node.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23579,7 +24019,7 @@ var ts; 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 === 212) { + else if (node.parent.kind === 214) { 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 : @@ -23605,7 +24045,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 185) { + if (element.kind !== 187) { elements.push(element); } } @@ -23671,7 +24111,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 143 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 145 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -23684,7 +24124,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 143 + return accessor.kind === 145 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -23693,7 +24133,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 144) { + if (accessorWithTypeAnnotation.kind === 146) { 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 : @@ -23739,17 +24179,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 211) { + if (node.kind === 213) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 141) { + else if (node.kind === 143) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 211) { + if (node.kind === 213) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 142) { + else if (node.kind === 144) { write("constructor"); } else { @@ -23766,11 +24206,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 146 || node.kind === 151) { + if (node.kind === 148 || node.kind === 153) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 147) { + if (node.kind === 149) { write("["); } else { @@ -23779,20 +24219,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 147) { + if (node.kind === 149) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 150 || node.kind === 151; - if (isFunctionTypeOrConstructorType || node.parent.kind === 153) { + var isFunctionTypeOrConstructorType = node.kind === 152 || node.kind === 153; + if (isFunctionTypeOrConstructorType || node.parent.kind === 155) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 142 && !(node.flags & 32)) { + else if (node.kind !== 144 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -23803,23 +24243,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 146: + case 148: 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 145: + case 147: 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 147: + case 149: 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 141: - case 140: + case 143: + case 142: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23827,7 +24267,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 === 212) { + else if (node.parent.kind === 214) { 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 : @@ -23840,7 +24280,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 211: + case 213: 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 : @@ -23872,9 +24312,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 150 || - node.parent.kind === 151 || - node.parent.parent.kind === 153) { + if (node.parent.kind === 152 || + node.parent.kind === 153 || + node.parent.parent.kind === 155) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -23890,22 +24330,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 142: + case 144: return 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; - case 146: + case 148: return 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; - case 145: + case 147: return 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; - case 141: - case 140: + case 143: + case 142: if (node.parent.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23913,7 +24353,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 === 212) { + else if (node.parent.parent.kind === 214) { return 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 : @@ -23925,7 +24365,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 211: + case 213: return 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 : @@ -23936,12 +24376,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 159) { + if (bindingPattern.kind === 161) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 160) { + else if (bindingPattern.kind === 162) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -23960,10 +24400,10 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 185) { + if (bindingElement.kind === 187) { write(" "); } - else if (bindingElement.kind === 161) { + else if (bindingElement.kind === 163) { if (bindingElement.propertyName) { writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); @@ -23973,7 +24413,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 67); + ts.Debug.assert(bindingElement.name.kind === 69); if (bindingElement.dotDotDotToken) { write("..."); } @@ -23985,39 +24425,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 211: - case 216: - case 219: case 213: - case 212: - case 214: + case 218: + case 221: case 215: + case 214: + case 216: + case 217: return emitModuleElement(node, isModuleElementVisible(node)); - case 191: + case 193: return emitModuleElement(node, isVariableStatementVisible(node)); - case 220: + case 222: return emitModuleElement(node, !node.importClause); - case 226: + case 228: return emitExportDeclaration(node); + case 144: + case 143: case 142: - case 141: - case 140: return writeFunctionDeclaration(node); - case 146: - case 145: + case 148: case 147: + case 149: return emitSignatureDeclarationWithJsDocComments(node); - case 143: - case 144: + case 145: + case 146: return emitAccessorDeclaration(node); - case 139: - case 138: + case 141: + case 140: return emitPropertyDeclaration(node); - case 245: + case 247: return emitEnumMemberDeclaration(node); - case 225: + case 227: return emitExportAssignment(node); - case 246: + case 248: return emitSourceFile(node); } } @@ -24060,14 +24500,270 @@ var ts; return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); } ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; + var entities = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; function emitFiles(resolver, host, targetSourceFile) { var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; - var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; + var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var diagnostics = []; var newLine = host.getNewLine(); @@ -24147,6 +24843,14 @@ var ts; var scopeEmitEnd = function () { }; var sourceMapData; var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; + var moduleEmitDelegates = (_a = {}, + _a[5] = emitES6Module, + _a[2] = emitAMDModule, + _a[4] = emitSystemModule, + _a[3] = emitUMDModule, + _a[1] = emitCommonJSModule, + _a + ); if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { initializeEmitterWithSourceMaps(); } @@ -24223,19 +24927,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 67: + case 69: return makeUniqueName(node.text); - case 216: - case 215: + case 218: + case 217: return generateNameForModuleOrEnum(node); - case 220: - case 226: + case 222: + case 228: return generateNameForImportOrExportDeclaration(node); - case 211: - case 212: - case 225: + case 213: + case 214: + case 227: return generateNameForExportDefault(); - case 184: + case 186: return generateNameForClassExpression(); } } @@ -24374,7 +25078,7 @@ var ts; var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { var name_22 = node.name; - if (!name_22 || name_22.kind !== 134) { + if (!name_22 || name_22.kind !== 136) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -24391,18 +25095,18 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 211 || - node.kind === 171 || - node.kind === 141 || - node.kind === 140 || + else if (node.kind === 213 || + node.kind === 173 || node.kind === 143 || - node.kind === 144 || - node.kind === 216 || - node.kind === 212 || - node.kind === 215) { + node.kind === 142 || + node.kind === 145 || + node.kind === 146 || + node.kind === 218 || + node.kind === 214 || + node.kind === 217) { if (node.name) { var name_23 = node.name; - scopeName = name_23.kind === 134 + scopeName = name_23.kind === 136 ? ts.getTextOfNode(name_23) : node.name.text; } @@ -24501,7 +25205,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node); } - if (node.kind !== 246) { + if (node.kind !== 248) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); @@ -24528,7 +25232,7 @@ var ts; ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); } function createTempVariable(flags) { - var result = ts.createSynthesizedNode(67); + var result = ts.createSynthesizedNode(69); result.text = makeTempVariableName(flags); return result; } @@ -24751,10 +25455,10 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 181) { + if (node.template.kind === 183) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 179 + var needsParens = templateSpan.expression.kind === 181 && templateSpan.expression.operatorToken.kind === 24; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -24778,7 +25482,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 170 + var needsParens = templateSpan.expression.kind !== 172 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -24798,11 +25502,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 166: - case 167: - return parent.expression === template; case 168: + case 169: + return parent.expression === template; case 170: + case 172: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -24810,11 +25514,11 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 179: + case 181: switch (expression.operatorToken.kind) { case 37: - case 38: case 39: + case 40: return 1; case 35: case 36: @@ -24822,8 +25526,8 @@ var ts; default: return -1; } + case 184: case 182: - case 180: return -1; default: return 1; @@ -24836,7 +25540,7 @@ var ts; } function jsxEmitReact(node) { function emitTagName(name) { - if (name.kind === 67 && ts.isIntrinsicJsxName(name.text)) { + if (name.kind === 69 && ts.isIntrinsicJsxName(name.text)) { write("\""); emit(name); write("\""); @@ -24866,8 +25570,8 @@ var ts; } } function emitJsxElement(openingNode, children) { - var syntheticReactRef = ts.createSynthesizedNode(67); - syntheticReactRef.text = 'React'; + var syntheticReactRef = ts.createSynthesizedNode(69); + syntheticReactRef.text = "React"; syntheticReactRef.parent = openingNode; emitLeadingComments(openingNode); emitExpressionIdentifier(syntheticReactRef); @@ -24879,12 +25583,12 @@ var ts; } else { var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 237; })) { + if (ts.forEach(attrs, function (attr) { return attr.kind === 239; })) { emitExpressionIdentifier(syntheticReactRef); write(".__spread("); var haveOpenedObjectLiteral = false; for (var i_1 = 0; i_1 < attrs.length; i_1++) { - if (attrs[i_1].kind === 237) { + if (attrs[i_1].kind === 239) { if (i_1 === 0) { write("{}, "); } @@ -24898,7 +25602,7 @@ var ts; emit(attrs[i_1].expression); } else { - ts.Debug.assert(attrs[i_1].kind === 236); + ts.Debug.assert(attrs[i_1].kind === 238); if (haveOpenedObjectLiteral) { write(", "); } @@ -24929,10 +25633,10 @@ var ts; } if (children) { for (var i = 0; i < children.length; i++) { - if (children[i].kind === 238 && !(children[i].expression)) { + if (children[i].kind === 240 && !(children[i].expression)) { continue; } - if (children[i].kind === 234) { + if (children[i].kind === 236) { var text = getTextToEmit(children[i]); if (text !== undefined) { write(", \""); @@ -24949,11 +25653,11 @@ var ts; write(")"); emitTrailingComments(openingNode); } - if (node.kind === 231) { + if (node.kind === 233) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 232); + ts.Debug.assert(node.kind === 234); emitJsxElement(node); } } @@ -24975,11 +25679,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 237) { + if (attribs[i].kind === 239) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 236); + ts.Debug.assert(attribs[i].kind === 238); emitJsxAttribute(attribs[i]); } } @@ -24987,11 +25691,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 232)) { + if (node.attributes.length > 0 || (node.kind === 234)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 232) { + if (node.kind === 234) { write("/>"); } else { @@ -25010,20 +25714,20 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 231) { + if (node.kind === 233) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 232); + ts.Debug.assert(node.kind === 234); emitJsxOpeningOrSelfClosingElement(node); } } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 161); + ts.Debug.assert(node.kind !== 163); if (node.kind === 9) { emitLiteral(node); } - else if (node.kind === 134) { + else if (node.kind === 136) { if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; @@ -25054,60 +25758,61 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 162: - case 179: - case 166: - case 239: - case 134: - case 180: - case 137: - case 173: - case 195: - case 165: - case 225: - case 193: - case 186: + case 164: + case 189: + case 181: + case 168: + case 241: + case 136: + case 182: + case 139: + case 175: case 197: - case 198: - case 199: - case 194: - case 232: - case 233: - case 237: - case 238: case 167: - case 170: - case 178: - case 177: - case 202: - case 244: - case 183: - case 204: - case 168: + case 227: + case 195: case 188: - case 206: - case 169: - case 174: - case 175: + case 199: + case 200: + case 201: case 196: - case 203: - case 182: + case 234: + case 235: + case 239: + case 240: + case 169: + case 172: + case 180: + case 179: + case 204: + case 246: + case 185: + case 206: + case 170: + case 190: + case 208: + case 171: + case 176: + case 177: + case 198: + case 205: + case 184: return true; - case 161: + case 163: + case 247: + case 138: case 245: - case 136: - case 243: - case 139: - case 209: + case 141: + case 211: return parent.initializer === node; - case 164: + case 166: return parent.expression === node; - case 172: - case 171: + case 174: + case 173: return parent.body === node; - case 219: + case 221: return parent.moduleReference === node; - case 133: + case 135: return parent.left === node; } return false; @@ -25119,8 +25824,8 @@ var ts; } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 246) { - if (languageVersion < 2 && compilerOptions.module !== 4) { + if (container.kind === 248) { + if (modulekind !== 5 && modulekind !== 4) { write("exports."); } } @@ -25129,18 +25834,18 @@ var ts; write("."); } } - else if (languageVersion < 2) { + else if (modulekind !== 5) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 221) { + if (declaration.kind === 223) { write(getGeneratedNameForNode(declaration.parent)); write(languageVersion === 0 ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 224) { + else if (declaration.kind === 226) { write(getGeneratedNameForNode(declaration.parent.parent.parent)); - var name = declaration.propertyName || declaration.name; - var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name); + var name_24 = declaration.propertyName || declaration.name; + var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name_24); if (languageVersion === 0 && identifier === "default") { write("[\"default\"]"); } @@ -25168,10 +25873,10 @@ var ts; if (languageVersion < 2) { var parent_6 = node.parent; switch (parent_6.kind) { - case 161: - case 212: - case 215: - case 209: + case 163: + case 214: + case 217: + case 211: return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); } } @@ -25249,7 +25954,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(112)); + write(ts.tokenToString(114)); if (node.asteriskToken) { write("*"); } @@ -25263,7 +25968,7 @@ var ts; if (needsParenthesis) { write("("); } - write(ts.tokenToString(112)); + write(ts.tokenToString(114)); write(" "); emit(node.expression); if (needsParenthesis) { @@ -25271,22 +25976,22 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 179 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 181 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 180 && node.parent.condition === node) { + else if (node.parent.kind === 182 && node.parent.condition === node) { return true; } return false; } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 67: - case 162: + case 69: case 164: - case 165: case 166: - case 170: + case 167: + case 168: + case 172: return false; } return true; @@ -25303,17 +26008,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 183) { + if (e.kind === 185) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 164) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 183) { + while (i < length && elements[i].kind !== 185) { i++; } write("["); @@ -25336,7 +26041,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 183; + return node.kind === 185; } function emitArrayLiteral(node) { var elements = node.elements; @@ -25397,7 +26102,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 143 || property.kind === 144) { + if (property.kind === 145 || property.kind === 146) { var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { continue; @@ -25448,13 +26153,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 243) { + if (property.kind === 245) { emit(property.initializer); } - else if (property.kind === 244) { + else if (property.kind === 246) { emitExpressionIdentifier(property.name); } - else if (property.kind === 141) { + else if (property.kind === 143) { emitFunctionDeclaration(property); } else { @@ -25486,7 +26191,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 === 134) { + if (properties[i].name.kind === 136) { numInitialNonComputedProperties = i; break; } @@ -25500,35 +26205,35 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(179, startsOnNewLine); + var result = ts.createSynthesizedNode(181, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(164); + var result = ts.createSynthesizedNode(166); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(21); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(165); + var result = ts.createSynthesizedNode(167); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; } function parenthesizeForAccess(expr) { - while (expr.kind === 169 || expr.kind === 187) { + while (expr.kind === 171 || expr.kind === 189) { expr = expr.expression; } if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 167 && + expr.kind !== 169 && expr.kind !== 8) { return expr; } - var node = ts.createSynthesizedNode(170); + var node = ts.createSynthesizedNode(172); node.expression = expr; return node; } @@ -25555,7 +26260,7 @@ var ts; } function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 246; + return container && container.kind !== 248; } function emitShorthandPropertyAssignment(node) { writeTextOfNode(currentSourceFile, node.name); @@ -25563,13 +26268,17 @@ var ts; write(": "); emit(node.name); } + if (languageVersion >= 2 && node.objectAssignmentInitializer) { + write(" = "); + emit(node.objectAssignmentInitializer); + } } function tryEmitConstantValue(node) { var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 164 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 166 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -25580,7 +26289,7 @@ var ts; if (compilerOptions.isolatedModules) { return undefined; } - return node.kind === 164 || node.kind === 165 + return node.kind === 166 || node.kind === 167 ? resolver.getConstantValue(node) : undefined; } @@ -25632,7 +26341,7 @@ var ts; emit(node.right); } function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 67) { + if (node.left.kind === 69) { emitEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -25652,7 +26361,7 @@ var ts; } function emitEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 67: + case 69: if (useFallback) { write("typeof "); emitExpressionIdentifier(node); @@ -25660,7 +26369,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 133: + case 135: emitQualifiedNameAsExpression(node, useFallback); break; } @@ -25675,16 +26384,16 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 183; }); + return ts.forEach(elements, function (e) { return e.kind === 185; }); } function skipParentheses(node) { - while (node.kind === 170 || node.kind === 169 || node.kind === 187) { + while (node.kind === 172 || node.kind === 171 || node.kind === 189) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 67 || node.kind === 95 || node.kind === 93) { + if (node.kind === 69 || node.kind === 97 || node.kind === 95) { emit(node); return node; } @@ -25699,18 +26408,18 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 164) { + if (expr.kind === 166) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 165) { + else if (expr.kind === 167) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 93) { + else if (expr.kind === 95) { target = expr; write("_super"); } @@ -25719,7 +26428,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 93) { + if (target.kind === 95) { emitThis(target); } else { @@ -25739,13 +26448,13 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 93) { + if (node.expression.kind === 95) { emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 164 && node.expression.expression.kind === 93; + superCall = node.expression.kind === 166 && node.expression.expression.kind === 95; } if (superCall && languageVersion < 2) { write(".call("); @@ -25796,21 +26505,21 @@ var ts; } } function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172) { - if (node.expression.kind === 169 || node.expression.kind === 187) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 174) { + if (node.expression.kind === 171 || node.expression.kind === 189) { var operand = node.expression.expression; - while (operand.kind === 169 || operand.kind === 187) { + while (operand.kind === 171 || operand.kind === 189) { operand = operand.expression; } - if (operand.kind !== 177 && + if (operand.kind !== 179 && + operand.kind !== 177 && + operand.kind !== 176 && operand.kind !== 175 && - operand.kind !== 174 && - operand.kind !== 173 && - operand.kind !== 178 && - operand.kind !== 167 && - !(operand.kind === 166 && node.parent.kind === 167) && - !(operand.kind === 171 && node.parent.kind === 166) && - !(operand.kind === 8 && node.parent.kind === 164)) { + operand.kind !== 180 && + operand.kind !== 169 && + !(operand.kind === 168 && node.parent.kind === 169) && + !(operand.kind === 173 && node.parent.kind === 168) && + !(operand.kind === 8 && node.parent.kind === 166)) { emit(operand); return; } @@ -25821,25 +26530,25 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(76)); + write(ts.tokenToString(78)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(101)); + write(ts.tokenToString(103)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(99)); + write(ts.tokenToString(101)); write(" "); emit(node.expression); } function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 67 || ts.nodeIsSynthesized(node)) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 69 || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 || node.parent.kind === 161); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 211 || node.parent.kind === 163); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -25853,12 +26562,12 @@ var ts; write("\", "); } write(ts.tokenToString(node.operator)); - if (node.operand.kind === 177) { + if (node.operand.kind === 179) { var operand = node.operand; - if (node.operator === 35 && (operand.operator === 35 || operand.operator === 40)) { + if (node.operator === 35 && (operand.operator === 35 || operand.operator === 41)) { write(" "); } - else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 41)) { + else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) { write(" "); } } @@ -25875,7 +26584,7 @@ var ts; write("\", "); write(ts.tokenToString(node.operator)); emit(node.operand); - if (node.operator === 40) { + if (node.operator === 41) { write(") - 1)"); } else { @@ -25896,10 +26605,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 246) { + if (current.kind === 248) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 217) { + else if (ts.isFunctionLike(current) || current.kind === 219) { return false; } else { @@ -25907,26 +26616,82 @@ var ts; } } } + function emitExponentiationOperator(node) { + var leftHandSideExpression = node.left; + if (node.operatorToken.kind === 60) { + var synthesizedLHS; + var shouldEmitParentheses = false; + if (ts.isElementAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(167, false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); + synthesizedLHS.expression = identifier; + if (leftHandSideExpression.argumentExpression.kind !== 8 && + leftHandSideExpression.argumentExpression.kind !== 9) { + var tempArgumentExpression = createAndRecordTempVariable(268435456); + synthesizedLHS.argumentExpression = tempArgumentExpression; + emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, true); + } + else { + synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; + } + write(", "); + } + else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(166, false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); + synthesizedLHS.expression = identifier; + synthesizedLHS.dotToken = leftHandSideExpression.dotToken; + synthesizedLHS.name = leftHandSideExpression.name; + write(", "); + } + emit(synthesizedLHS || leftHandSideExpression); + write(" = "); + write("Math.pow("); + emit(synthesizedLHS || leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + if (shouldEmitParentheses) { + write(")"); + } + } + else { + write("Math.pow("); + emit(leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + } + } function emitBinaryExpression(node) { - if (languageVersion < 2 && node.operatorToken.kind === 55 && - (node.left.kind === 163 || node.left.kind === 162)) { - emitDestructuring(node, node.parent.kind === 193); + if (languageVersion < 2 && node.operatorToken.kind === 56 && + (node.left.kind === 165 || node.left.kind === 164)) { + emitDestructuring(node, node.parent.kind === 195); } else { - var exportChanged = node.operatorToken.kind >= 55 && - node.operatorToken.kind <= 66 && + var exportChanged = node.operatorToken.kind >= 56 && + node.operatorToken.kind <= 68 && isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); if (exportChanged) { write(exportFunctionForFile + "(\""); emitNodeWithoutSourceMap(node.left); write("\", "); } - emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); - write(ts.tokenToString(node.operatorToken.kind)); - var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); - emit(node.right); - decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + if (node.operatorToken.kind === 38 || node.operatorToken.kind === 60) { + emitExponentiationOperator(node); + } + else { + emit(node.left); + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); + write(ts.tokenToString(node.operatorToken.kind)); + var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); + emit(node.right); + decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + } if (exportChanged) { write(")"); } @@ -25957,7 +26722,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 190) { + if (node && node.kind === 192) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -25972,12 +26737,12 @@ var ts; emitToken(15, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 217) { - ts.Debug.assert(node.parent.kind === 216); + if (node.kind === 219) { + ts.Debug.assert(node.parent.kind === 218); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 217) { + if (node.kind === 219) { emitTempDeclarations(true); } decreaseIndent(); @@ -25986,7 +26751,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 190) { + if (node.kind === 192) { write(" "); emit(node); } @@ -25998,11 +26763,11 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 172); + emitParenthesizedIf(node.expression, node.expression.kind === 174); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(86, node.pos); + var endPos = emitToken(88, node.pos); write(" "); endPos = emitToken(17, endPos); emit(node.expression); @@ -26010,8 +26775,8 @@ var ts; emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(78, node.thenStatement.end); - if (node.elseStatement.kind === 194) { + emitToken(80, node.thenStatement.end); + if (node.elseStatement.kind === 196) { write(" "); emit(node.elseStatement); } @@ -26023,7 +26788,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 190) { + if (node.statement.kind === 192) { write(" "); } else { @@ -26043,13 +26808,13 @@ var ts; if (shouldHoistVariable(decl, true)) { return false; } - var tokenKind = 100; + var tokenKind = 102; if (decl && languageVersion >= 2) { if (ts.isLet(decl)) { - tokenKind = 106; + tokenKind = 108; } else if (ts.isConst(decl)) { - tokenKind = 72; + tokenKind = 74; } } if (startPos !== undefined) { @@ -26058,13 +26823,13 @@ var ts; } else { switch (tokenKind) { - case 100: + case 102: write("var "); break; - case 106: + case 108: write("let "); break; - case 72: + case 74: write("const "); break; } @@ -26089,10 +26854,10 @@ var ts; return started; } function emitForStatement(node) { - var endPos = emitToken(84, node.pos); + var endPos = emitToken(86, node.pos); write(" "); endPos = emitToken(17, endPos); - if (node.initializer && node.initializer.kind === 210) { + if (node.initializer && node.initializer.kind === 212) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -26113,13 +26878,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 199) { + if (languageVersion < 2 && node.kind === 201) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(84, node.pos); + var endPos = emitToken(86, node.pos); write(" "); endPos = emitToken(17, endPos); - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -26129,7 +26894,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 198) { + if (node.kind === 200) { write(" in "); } else { @@ -26140,10 +26905,10 @@ var ts; emitEmbeddedStatement(node.statement); } function emitDownLevelForOfStatement(node) { - var endPos = emitToken(84, node.pos); + var endPos = emitToken(86, node.pos); write(" "); endPos = emitToken(17, endPos); - var rhsIsIdentifier = node.expression.kind === 67; + var rhsIsIdentifier = node.expression.kind === 69; var counter = createTempVariable(268435456); var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); emitStart(node.expression); @@ -26177,7 +26942,7 @@ var ts; increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -26198,8 +26963,8 @@ var ts; } } else { - var assignmentExpression = createBinaryExpression(node.initializer, 55, rhsIterationValue, false); - if (node.initializer.kind === 162 || node.initializer.kind === 163) { + var assignmentExpression = createBinaryExpression(node.initializer, 56, rhsIterationValue, false); + if (node.initializer.kind === 164 || node.initializer.kind === 165) { emitDestructuring(assignmentExpression, true, undefined); } else { @@ -26208,7 +26973,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 190) { + if (node.statement.kind === 192) { emitLines(node.statement.statements); } else { @@ -26220,12 +26985,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 201 ? 68 : 73, node.pos); + emitToken(node.kind === 203 ? 70 : 75, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(92, node.pos); + emitToken(94, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -26236,7 +27001,7 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(94, node.pos); + var endPos = emitToken(96, node.pos); write(" "); emitToken(17, endPos); emit(node.expression); @@ -26265,7 +27030,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 239) { + if (node.kind === 241) { write("case "); emit(node.expression); write(":"); @@ -26300,7 +27065,7 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(70, node.pos); + var endPos = emitToken(72, node.pos); write(" "); emitToken(17, endPos); emit(node.variableDeclaration); @@ -26309,7 +27074,7 @@ var ts; emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(74, node.pos); + emitToken(76, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -26320,7 +27085,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 216); + } while (node && node.kind !== 218); return node; } function emitContainingModuleName(node) { @@ -26335,7 +27100,7 @@ var ts; write(getGeneratedNameForNode(container)); write("."); } - else if (languageVersion < 2 && compilerOptions.module !== 4) { + else if (modulekind !== 5 && modulekind !== 4) { write("exports."); } } @@ -26345,14 +27110,14 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(8); zero.text = "0"; - var result = ts.createSynthesizedNode(175); + var result = ts.createSynthesizedNode(177); result.expression = zero; return result; } function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 246) { - ts.Debug.assert(!!(node.flags & 1024) || node.kind === 225); - if (compilerOptions.module === 1 || compilerOptions.module === 2 || compilerOptions.module === 3) { + if (node.parent.kind === 248) { + ts.Debug.assert(!!(node.flags & 1024) || node.kind === 227); + if (modulekind === 1 || modulekind === 2 || modulekind === 3) { if (!currentSourceFile.symbol.exports["___esModule"]) { if (languageVersion === 1) { write("Object.defineProperty(exports, \"__esModule\", { value: true });"); @@ -26370,7 +27135,7 @@ var ts; if (node.flags & 1) { writeLine(); emitStart(node); - if (compilerOptions.module === 4 && node.parent === currentSourceFile) { + if (modulekind === 4 && node.parent === currentSourceFile) { write(exportFunctionForFile + "(\""); if (node.flags & 1024) { write("default"); @@ -26403,7 +27168,7 @@ var ts; } } function emitExportMemberAssignments(name) { - if (compilerOptions.module === 4) { + if (modulekind === 4) { return; } if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { @@ -26422,7 +27187,7 @@ var ts; } } function emitExportSpecifierInSystemModule(specifier) { - ts.Debug.assert(compilerOptions.module === 4); + ts.Debug.assert(modulekind === 4); if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { return; } @@ -26436,72 +27201,77 @@ var ts; emitEnd(specifier.name); write(";"); } + function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { + if (shouldEmitCommaBeforeAssignment) { + write(", "); + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(name); + write("\", "); + } + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 211 || name.parent.kind === 163); + if (isVariableDeclarationOrBindingElement) { + emitModuleMemberName(name.parent); + } + else { + emit(name); + } + write(" = "); + emit(value); + if (exportChanged) { + write(")"); + } + } + function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { + var identifier = createTempVariable(0); + if (!canDefineTempVariablesInPlace) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); + return identifier; + } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; var canDefineTempVariablesInPlace = false; - if (root.kind === 209) { + if (root.kind === 211) { var isExported = ts.getCombinedNodeFlags(root) & 1; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 136) { + else if (root.kind === 138) { canDefineTempVariablesInPlace = true; } - if (root.kind === 179) { + if (root.kind === 181) { emitAssignmentExpression(root); } else { ts.Debug.assert(!isAssignmentExpressionStatement); emitBindingElement(root, value); } - function emitAssignment(name, value) { - if (emitCount++) { - write(", "); - } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 || name.parent.kind === 161); - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(name); - write("\", "); - } - if (isVariableDeclarationOrBindingElement) { - emitModuleMemberName(name.parent); - } - else { - emit(name); - } - write(" = "); - emit(value); - if (exportChanged) { - write(")"); - } - } function ensureIdentifier(expr, reuseIdentifierExpressions) { - if (expr.kind === 67 && reuseIdentifierExpressions) { + if (expr.kind === 69 && reuseIdentifierExpressions) { return expr; } - var identifier = createTempVariable(0); - if (!canDefineTempVariablesInPlace) { - recordTempDeclaration(identifier); - } - emitAssignment(identifier, expr); + var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); + emitCount++; return identifier; } function createDefaultValueCheck(value, defaultValue) { value = ensureIdentifier(value, true); - var equals = ts.createSynthesizedNode(179); + var equals = ts.createSynthesizedNode(181); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(32); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(180); + var cond = ts.createSynthesizedNode(182); cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(52); + cond.questionToken = ts.createSynthesizedNode(53); cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(53); + cond.colonToken = ts.createSynthesizedNode(54); cond.whenFalse = whenFalse; return cond; } @@ -26513,14 +27283,14 @@ var ts; function createPropertyAccessForDestructuringProperty(object, propName) { var syntheticName = ts.createSynthesizedNode(propName.kind); syntheticName.text = propName.text; - if (syntheticName.kind !== 67) { + if (syntheticName.kind !== 69) { return createElementAccessExpression(object, syntheticName); } return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(166); - var sliceIdentifier = ts.createSynthesizedNode(67); + var call = ts.createSynthesizedNode(168); + var sliceIdentifier = ts.createSynthesizedNode(69); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); call.arguments = ts.createSynthesizedNodeArray(); @@ -26534,9 +27304,10 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 243 || p.kind === 244) { + if (p.kind === 245 || p.kind === 246) { var propName = p.name; - emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); + var target_1 = p.kind === 246 ? p : p.initializer || propName; + emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); } } } @@ -26547,8 +27318,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 185) { - if (e.kind !== 183) { + if (e.kind !== 187) { + if (e.kind !== 185) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -26558,18 +27329,25 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 179 && target.operatorToken.kind === 55) { + if (target.kind === 246) { + if (target.objectAssignmentInitializer) { + value = createDefaultValueCheck(value, target.objectAssignmentInitializer); + } + target = target.name; + } + else if (target.kind === 181 && target.operatorToken.kind === 56) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 163) { + if (target.kind === 165) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 162) { + else if (target.kind === 164) { emitArrayLiteralAssignment(target, value); } else { - emitAssignment(target, value); + emitAssignment(target, value, emitCount > 0); + emitCount++; } } function emitAssignmentExpression(root) { @@ -26582,14 +27360,14 @@ var ts; emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 170) { + if (root.parent.kind !== 172) { write("("); } value = ensureIdentifier(value, true); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 170) { + if (root.parent.kind !== 172) { write(")"); } } @@ -26610,11 +27388,11 @@ var ts; } for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (pattern.kind === 159) { + if (pattern.kind === 161) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 185) { + else if (element.kind !== 187) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } @@ -26625,7 +27403,8 @@ var ts; } } else { - emitAssignment(target.name, value); + emitAssignment(target.name, value, emitCount > 0); + emitCount++; } } } @@ -26645,8 +27424,8 @@ var ts; var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384) && (getCombinedFlagsForIdentifier(node.name) & 16384); if (isUninitializedLet && - node.parent.parent.kind !== 198 && - node.parent.parent.kind !== 199) { + node.parent.parent.kind !== 200 && + node.parent.parent.kind !== 201) { initializer = createVoidZero(); } } @@ -26664,11 +27443,11 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 185) { + if (node.kind === 187) { return; } var name = node.name; - if (name.kind === 67) { + if (name.kind === 69) { emitExportMemberAssignments(name); } else if (ts.isBindingPattern(name)) { @@ -26676,15 +27455,15 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 209 && node.parent.kind !== 161)) { + if (!node.parent || (node.parent.kind !== 211 && node.parent.kind !== 163)) { return 0; } return ts.getCombinedNodeFlags(node.parent); } function isES6ExportedDeclaration(node) { return !!(node.flags & 1) && - languageVersion >= 2 && - node.parent.kind === 246; + modulekind === 5 && + node.parent.kind === 248; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -26707,7 +27486,7 @@ var ts; write(";"); } } - if (languageVersion < 2 && node.parent === currentSourceFile) { + if (modulekind !== 5 && node.parent === currentSourceFile) { ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); } } @@ -26729,12 +27508,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2) { if (ts.isBindingPattern(node.name)) { - var name_24 = createTempVariable(0); + var name_25 = createTempVariable(0); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_24); - emit(name_24); + tempParameters.push(name_25); + emit(name_25); } else { emit(node.name); @@ -26833,12 +27612,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 143 ? "get " : "set "); + write(node.kind === 145 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 172 && languageVersion >= 2; + return node.kind === 174 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { @@ -26849,10 +27628,10 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 171) { + if (node.kind === 173) { return !!node.name; } - if (node.kind === 211) { + if (node.kind === 213) { return !!node.name || languageVersion < 2; } } @@ -26860,9 +27639,9 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitCommentsOnNotEmittedNode(node); } - if (node.kind !== 141 && node.kind !== 140 && - node.parent && node.parent.kind !== 243 && - node.parent.kind !== 166) { + if (node.kind !== 143 && node.kind !== 142 && + node.parent && node.parent.kind !== 245 && + node.parent.kind !== 168) { emitLeadingComments(node); } emitStart(node); @@ -26883,11 +27662,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 211 && node.parent === currentSourceFile && node.name) { + if (modulekind !== 5 && node.kind === 213 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } emitEnd(node); - if (node.kind !== 141 && node.kind !== 140) { + if (node.kind !== 143 && node.kind !== 142) { emitTrailingComments(node); } } @@ -26919,7 +27698,7 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 172; + var isArrowFunction = node.kind === 174; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; var args; if (!isArrowFunction) { @@ -26962,7 +27741,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 190) { + if (node.body.kind === 192) { emitBlockFunctionBody(node, node.body); } else { @@ -27010,10 +27789,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 169) { + while (current.kind === 171) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 163); + emitParenthesizedIf(body, current.kind === 165); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -27085,11 +27864,11 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 193) { + if (statement && statement.kind === 195) { var expr = statement.expression; - if (expr && expr.kind === 166) { + if (expr && expr.kind === 168) { var func = expr.expression; - if (func && func.kind === 93) { + if (func && func.kind === 95) { return statement; } } @@ -27118,7 +27897,7 @@ var ts; emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 134) { + else if (memberName.kind === 136) { emitComputedPropertyName(memberName); } else { @@ -27130,7 +27909,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 139 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + if (member.kind === 141 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { properties.push(member); } } @@ -27170,11 +27949,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 189) { + if (member.kind === 191) { writeLine(); write(";"); } - else if (member.kind === 141 || node.kind === 140) { + else if (member.kind === 143 || node.kind === 142) { if (!member.body) { return emitCommentsOnNotEmittedNode(member); } @@ -27191,7 +27970,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 143 || member.kind === 144) { + else if (member.kind === 145 || member.kind === 146) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -27241,22 +28020,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 141 || node.kind === 140) && !member.body) { + if ((member.kind === 143 || node.kind === 142) && !member.body) { emitCommentsOnNotEmittedNode(member); } - else if (member.kind === 141 || - member.kind === 143 || - member.kind === 144) { + else if (member.kind === 143 || + member.kind === 145 || + member.kind === 146) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128) { write("static "); } - if (member.kind === 143) { + if (member.kind === 145) { write("get "); } - else if (member.kind === 144) { + else if (member.kind === 146) { write("set "); } if (member.asteriskToken) { @@ -27267,7 +28046,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 189) { + else if (member.kind === 191) { writeLine(); write(";"); } @@ -27288,10 +28067,10 @@ var ts; function emitConstructorWorker(node, baseTypeElement) { var hasInstancePropertyWithInitializer = false; ts.forEach(node.members, function (member) { - if (member.kind === 142 && !member.body) { + if (member.kind === 144 && !member.body) { emitCommentsOnNotEmittedNode(member); } - if (member.kind === 139 && member.initializer && (member.flags & 128) === 0) { + if (member.kind === 141 && member.initializer && (member.flags & 128) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -27391,10 +28170,13 @@ var ts; else { emitClassLikeDeclarationForES6AndHigher(node); } + if (modulekind !== 5 && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 212) { + if (node.kind === 214) { if (thisNodeIsDecorated) { if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { write("export "); @@ -27411,7 +28193,7 @@ var ts; } } var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 186; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0); @@ -27421,7 +28203,7 @@ var ts; write(" = "); } write("class"); - if ((node.name || !(node.flags & 1024)) && !thisNodeIsDecorated) { + if ((node.name || (node.flags & 1024 && staticProperties.length > 0)) && !thisNodeIsDecorated) { write(" "); emitDeclarationName(node); } @@ -27478,7 +28260,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 212) { + if (node.kind === 214) { if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); } @@ -27536,16 +28318,13 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 212) { + if (node.kind === 214) { write(";"); } emitEnd(node); - if (node.kind === 212) { + if (node.kind === 214) { emitExportMemberAssignment(node); } - if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } } function emitClassMemberPrefix(node, member) { emitDeclarationName(node); @@ -27614,23 +28393,12 @@ var ts; } else { decorators = member.decorators; - if (member.kind === 141) { + if (member.kind === 143) { functionLikeMember = member; } } writeLine(); emitStart(member); - if (member.kind !== 139) { - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(","); - increaseIndent(); - writeLine(); - } write("__decorate(["); increaseIndent(); writeLine(); @@ -27650,15 +28418,13 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 139) { - write(", Object.getOwnPropertyDescriptor("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write("))"); - decreaseIndent(); + if (languageVersion > 0) { + if (member.kind !== 141) { + write(", null"); + } + else { + write(", void 0"); + } } write(");"); emitEnd(member); @@ -27689,45 +28455,45 @@ var ts; } function shouldEmitTypeMetadata(node) { switch (node.kind) { - case 141: case 143: - case 144: - case 139: + case 145: + case 146: + case 141: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { switch (node.kind) { - case 141: + case 143: return true; } return false; } function shouldEmitParamTypesMetadata(node) { switch (node.kind) { - case 212: - case 141: - case 144: + case 214: + case 143: + case 146: return true; } return false; } function emitSerializedTypeOfNode(node) { switch (node.kind) { - case 212: + case 214: write("Function"); return; - case 139: + case 141: emitSerializedTypeNode(node.type); return; - case 136: + case 138: emitSerializedTypeNode(node.type); return; - case 143: + case 145: emitSerializedTypeNode(node.type); return; - case 144: + case 146: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -27740,42 +28506,42 @@ var ts; function emitSerializedTypeNode(node) { if (node) { switch (node.kind) { - case 101: + case 103: write("void 0"); return; - case 158: + case 160: emitSerializedTypeNode(node.type); return; - case 150: - case 151: + case 152: + case 153: write("Function"); return; - case 154: - case 155: + case 156: + case 157: write("Array"); return; - case 148: - case 118: + case 150: + case 120: write("Boolean"); return; - case 128: + case 130: case 9: write("String"); return; - case 126: + case 128: write("Number"); return; - case 129: + case 131: write("Symbol"); return; - case 149: + case 151: emitSerializedTypeReferenceNode(node); return; - case 152: - case 153: - case 156: - case 157: - case 115: + case 154: + case 155: + case 158: + case 159: + case 117: break; default: ts.Debug.fail("Cannot serialize unexpected type node."); @@ -27840,7 +28606,7 @@ var ts; function emitSerializedParameterTypesOfNode(node) { if (node) { var valueDeclaration; - if (node.kind === 212) { + if (node.kind === 214) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -27856,10 +28622,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 154) { + if (parameterType.kind === 156) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 149 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 151 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -27971,8 +28737,8 @@ var ts; emitEnd(node); write(";"); } - if (languageVersion < 2 && node.parent === currentSourceFile) { - if (compilerOptions.module === 4 && (node.flags & 1)) { + if (modulekind !== 5 && node.parent === currentSourceFile) { + if (modulekind === 4 && (node.flags & 1)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -28012,7 +28778,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 216) { + if (moduleDeclaration.body.kind === 218) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -28047,7 +28813,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 217) { + if (node.body.kind === 219) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -28079,8 +28845,8 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 67 && node.parent === currentSourceFile) { - if (compilerOptions.module === 4 && (node.flags & 1)) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 69 && node.parent === currentSourceFile) { + if (modulekind === 4 && (node.flags & 1)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -28116,16 +28882,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 219) { + if (node.kind === 221) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 224) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 220 && node.importClause && !!node.importClause.name; + return node.kind === 222 && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -28134,7 +28900,7 @@ var ts; ts.forEachChild(node, emitExportImportAssignments); } function emitImportDeclaration(node) { - if (languageVersion < 2) { + if (modulekind !== 5) { return emitExternalImportDeclaration(node); } if (node.importClause) { @@ -28152,7 +28918,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 222) { + if (node.importClause.namedBindings.kind === 224) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -28178,9 +28944,9 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 219 && (node.flags & 1) !== 0; + var isExportedImport = node.kind === 221 && (node.flags & 1) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (compilerOptions.module !== 2) { + if (modulekind !== 2) { emitLeadingComments(node); emitStart(node); if (namespaceDeclaration && !isDefaultImport(node)) { @@ -28190,7 +28956,7 @@ var ts; write(" = "); } else { - var isNakedImport = 220 && !node.importClause; + var isNakedImport = 222 && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -28266,13 +29032,13 @@ var ts; } } function emitExportDeclaration(node) { - ts.Debug.assert(compilerOptions.module !== 4); - if (languageVersion < 2) { + ts.Debug.assert(modulekind !== 4); + if (modulekind !== 5) { if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { emitStart(node); var generatedName = getGeneratedNameForNode(node); if (node.exportClause) { - if (compilerOptions.module !== 2) { + if (modulekind !== 2) { write("var "); write(generatedName); write(" = "); @@ -28299,7 +29065,7 @@ var ts; else { writeLine(); write("__export("); - if (compilerOptions.module !== 2) { + if (modulekind !== 2) { emitRequire(ts.getExternalModuleName(node)); } else { @@ -28330,7 +29096,7 @@ var ts; } } function emitExportOrImportSpecifierList(specifiers, shouldEmit) { - ts.Debug.assert(languageVersion >= 2); + ts.Debug.assert(modulekind === 5); var needsComma = false; for (var _a = 0; _a < specifiers.length; _a++) { var specifier = specifiers[_a]; @@ -28349,14 +29115,14 @@ var ts; } function emitExportAssignment(node) { if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { - if (languageVersion >= 2) { + if (modulekind === 5) { writeLine(); emitStart(node); write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 211 && - expression.kind !== 212) { + if (expression.kind !== 213 && + expression.kind !== 214) { write(";"); } emitEnd(node); @@ -28364,7 +29130,7 @@ var ts; else { writeLine(); emitStart(node); - if (compilerOptions.module === 4) { + if (modulekind === 4) { write(exportFunctionForFile + "(\"default\","); emit(node.expression); write(")"); @@ -28393,18 +29159,18 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 220: + case 222: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { externalImports.push(node); } break; - case 219: - if (node.moduleReference.kind === 230 && resolver.isReferencedAliasDeclaration(node)) { + case 221: + if (node.moduleReference.kind === 232 && resolver.isReferencedAliasDeclaration(node)) { externalImports.push(node); } break; - case 226: + case 228: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -28417,12 +29183,12 @@ var ts; else { for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_25 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_25] || (exportSpecifiers[name_25] = [])).push(specifier); + var name_26 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_26] || (exportSpecifiers[name_26] = [])).push(specifier); } } break; - case 225: + case 227: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -28447,10 +29213,10 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - if (node.kind === 220 && node.importClause) { + if (node.kind === 222 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 226 && node.moduleSpecifier) { + if (node.kind === 228 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } @@ -28469,8 +29235,8 @@ var ts; var started = false; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; - var skipNode = importNode.kind === 226 || - (importNode.kind === 220 && !importNode.importClause); + var skipNode = importNode.kind === 228 || + (importNode.kind === 222 && !importNode.importClause); if (skipNode) { continue; } @@ -28495,7 +29261,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 226 && externalImport.exportClause) { + if (externalImport.kind === 228 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -28524,7 +29290,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 226) { + if (externalImport.kind !== 228) { continue; } var exportDecl = externalImport; @@ -28567,7 +29333,7 @@ var ts; return exportStarFunction; } function writeExportedName(node) { - if (node.kind !== 67 && node.flags & 1024) { + if (node.kind !== 69 && node.flags & 1024) { return; } if (started) { @@ -28578,7 +29344,7 @@ var ts; } writeLine(); write("'"); - if (node.kind === 67) { + if (node.kind === 69) { emitNodeWithCommentsAndWithoutSourcemap(node); } else { @@ -28598,11 +29364,11 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_26 = local.kind === 67 + var name_27 = local.kind === 69 ? local : local.name; - if (name_26) { - var text = ts.unescapeIdentifier(name_26.text); + if (name_27) { + var text = ts.unescapeIdentifier(name_27.text); if (ts.hasProperty(seen, text)) { continue; } @@ -28613,13 +29379,13 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 212 || local.kind === 216 || local.kind === 215) { + if (local.kind === 214 || local.kind === 218 || local.kind === 217) { emitDeclarationName(local); } else { emit(local); } - var flags = ts.getCombinedNodeFlags(local.kind === 67 ? local.parent : local); + var flags = ts.getCombinedNodeFlags(local.kind === 69 ? local.parent : local); if (flags & 1) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -28647,21 +29413,21 @@ var ts; if (node.flags & 2) { return; } - if (node.kind === 211) { + if (node.kind === 213) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 212) { + if (node.kind === 214) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 215) { + if (node.kind === 217) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -28670,7 +29436,7 @@ var ts; } return; } - if (node.kind === 216) { + if (node.kind === 218) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -28679,17 +29445,17 @@ var ts; } return; } - if (node.kind === 209 || node.kind === 161) { + if (node.kind === 211 || node.kind === 163) { if (shouldHoistVariable(node, false)) { - var name_27 = node.name; - if (name_27.kind === 67) { + var name_28 = node.name; + if (name_28.kind === 69) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_27); + hoistedVars.push(name_28); } else { - ts.forEachChild(name_27, visit); + ts.forEachChild(name_28, visit); } } return; @@ -28715,10 +29481,10 @@ var ts; return false; } return (ts.getCombinedNodeFlags(node) & 49152) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 246; + ts.getEnclosingBlockScopeContainer(node).kind === 248; } function isCurrentFileSystemExternalModule() { - return compilerOptions.module === 4 && ts.isExternalModule(currentSourceFile); + return modulekind === 4 && ts.isExternalModule(currentSourceFile); } function emitSystemModuleBody(node, dependencyGroups, startIndex) { emitVariableDeclarationsForImports(); @@ -28753,17 +29519,17 @@ var ts; var entry = group[_a]; var importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { - case 220: + case 222: if (!entry.importClause) { break; } - case 219: + case 221: ts.Debug.assert(importVariableName !== ""); writeLine(); write(importVariableName + " = " + parameterName + ";"); writeLine(); break; - case 226: + case 228: ts.Debug.assert(importVariableName !== ""); if (entry.exportClause) { writeLine(); @@ -28807,10 +29573,10 @@ var ts; for (var i = startIndex; i < node.statements.length; ++i) { var statement = node.statements[i]; switch (statement.kind) { - case 211: - case 220: + case 213: + case 222: continue; - case 226: + case 228: if (!statement.moduleSpecifier) { for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { var element = _b[_a]; @@ -28818,7 +29584,7 @@ var ts; } } continue; - case 219: + case 221: if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { continue; } @@ -28831,7 +29597,7 @@ var ts; writeLine(); write("}"); } - function emitSystemModule(node, startIndex) { + function emitSystemModule(node) { collectExternalModuleInfo(node); ts.Debug.assert(!exportFunctionForFile); exportFunctionForFile = makeUniqueName("exports"); @@ -28862,6 +29628,7 @@ var ts; write("], function(" + exportFunctionForFile + ") {"); writeLine(); increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitSystemModuleBody(node, dependencyGroups, startIndex); @@ -28869,7 +29636,7 @@ var ts; writeLine(); write("});"); } - function emitAMDDependencies(node, includeNonAmdDependencies) { + function getAMDDependencyNames(node, includeNonAmdDependencies) { var aliasedModuleNames = []; var unaliasedModuleNames = []; var importAliasNames = []; @@ -28895,6 +29662,16 @@ var ts; unaliasedModuleNames.push(externalModuleName); } } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + function emitAMDDependencies(node, includeNonAmdDependencies) { + var dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); + emitAMDDependencyList(dependencyNames); + write(", "); + emitAMDFactoryHeader(dependencyNames); + } + function emitAMDDependencyList(_a) { + var aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames; write("[\"require\", \"exports\""); if (aliasedModuleNames.length) { write(", "); @@ -28904,13 +29681,18 @@ var ts; write(", "); write(unaliasedModuleNames.join(", ")); } - write("], function (require, exports"); + write("]"); + } + function emitAMDFactoryHeader(_a) { + var importAliasNames = _a.importAliasNames; + write("function (require, exports"); if (importAliasNames.length) { write(", "); write(importAliasNames.join(", ")); } + write(") {"); } - function emitAMDModule(node, startIndex) { + function emitAMDModule(node) { emitEmitHelpers(node); collectExternalModuleInfo(node); writeLine(); @@ -28919,8 +29701,8 @@ var ts; write("\"" + node.moduleName + "\", "); } emitAMDDependencies(node, true); - write(") {"); increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -28930,7 +29712,8 @@ var ts; writeLine(); write("});"); } - function emitCommonJSModule(node, startIndex) { + function emitCommonJSModule(node) { + var startIndex = emitDirectivePrologues(node.statements, false); emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); @@ -28939,13 +29722,17 @@ var ts; emitTempDeclarations(true); emitExportEquals(false); } - function emitUMDModule(node, startIndex) { + function emitUMDModule(node) { emitEmitHelpers(node); collectExternalModuleInfo(node); - writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); - emitAMDDependencies(node, false); - write(") {"); + var dependencyNames = getAMDDependencyNames(node, false); + writeLines("(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define("); + emitAMDDependencyList(dependencyNames); + write(", factory);"); + writeLines(" }\n})("); + emitAMDFactoryHeader(dependencyNames); increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -28955,11 +29742,12 @@ var ts; writeLine(); write("});"); } - function emitES6Module(node, startIndex) { + function emitES6Module(node) { externalImports = undefined; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + var startIndex = emitDirectivePrologues(node.statements, false); emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -28996,7 +29784,7 @@ var ts; if (ts.isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + "\" + ' ' + \"" : "") + part; + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); } firstNonWhitespace = -1; } @@ -29009,7 +29797,7 @@ var ts; } if (firstNonWhitespace !== -1) { var part = text.substr(firstNonWhitespace); - result = (result ? result + "\" + ' ' + \"" : "") + part; + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); } if (result) { result = result.replace(/&(\w+);/g, function (s, m) { @@ -29117,25 +29905,12 @@ var ts; writeLine(); emitShebang(); emitDetachedComments(node); - var startIndex = emitDirectivePrologues(node.statements, false); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - if (languageVersion >= 2) { - emitES6Module(node, startIndex); - } - else if (compilerOptions.module === 2) { - emitAMDModule(node, startIndex); - } - else if (compilerOptions.module === 4) { - emitSystemModule(node, startIndex); - } - else if (compilerOptions.module === 3) { - emitUMDModule(node, startIndex); - } - else { - emitCommonJSModule(node, startIndex); - } + var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1]; + emitModule(node); } else { + var startIndex = emitDirectivePrologues(node.statements, false); externalImports = undefined; exportSpecifiers = undefined; exportEquals = undefined; @@ -29175,28 +29950,28 @@ var ts; } function isSpecializedCommentHandling(node) { switch (node.kind) { + case 215: case 213: - case 211: - case 220: - case 219: - case 214: - case 225: + case 222: + case 221: + case 216: + case 227: return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 191: + case 193: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 216: + case 218: return shouldEmitModuleDeclaration(node); - case 215: + case 217: return shouldEmitEnumDeclaration(node); } ts.Debug.assert(!isSpecializedCommentHandling(node)); - if (node.kind !== 190 && + if (node.kind !== 192 && node.parent && - node.parent.kind === 172 && + node.parent.kind === 174 && node.parent.body === node && compilerOptions.target <= 1) { return false; @@ -29205,25 +29980,25 @@ var ts; } function emitJavaScriptWorker(node) { switch (node.kind) { - case 67: + case 69: return emitIdentifier(node); - case 136: + case 138: return emitParameter(node); - case 141: - case 140: - return emitMethod(node); case 143: - case 144: + case 142: + return emitMethod(node); + case 145: + case 146: return emitAccessor(node); - case 95: + case 97: return emitThis(node); - case 93: + case 95: return emitSuper(node); - case 91: + case 93: return write("null"); - case 97: + case 99: return write("true"); - case 82: + case 84: return write("false"); case 8: case 9: @@ -29233,142 +30008,142 @@ var ts; case 13: case 14: return emitLiteral(node); - case 181: + case 183: return emitTemplateExpression(node); - case 188: + case 190: return emitTemplateSpan(node); - case 231: - case 232: - return emitJsxElement(node); + case 233: case 234: + return emitJsxElement(node); + case 236: return emitJsxText(node); - case 238: + case 240: return emitJsxExpression(node); - case 133: + case 135: return emitQualifiedName(node); - case 159: + case 161: return emitObjectBindingPattern(node); - case 160: + case 162: return emitArrayBindingPattern(node); - case 161: + case 163: return emitBindingElement(node); - case 162: + case 164: return emitArrayLiteral(node); - case 163: + case 165: return emitObjectLiteral(node); - case 243: + case 245: return emitPropertyAssignment(node); - case 244: + case 246: return emitShorthandPropertyAssignment(node); - case 134: + case 136: return emitComputedPropertyName(node); - case 164: + case 166: return emitPropertyAccess(node); - case 165: + case 167: return emitIndexedAccess(node); - case 166: + case 168: return emitCallExpression(node); - case 167: + case 169: return emitNewExpression(node); - case 168: + case 170: return emitTaggedTemplateExpression(node); - case 169: + case 171: return emit(node.expression); - case 187: + case 189: return emit(node.expression); - case 170: - return emitParenExpression(node); - case 211: - case 171: case 172: - return emitFunctionDeclaration(node); + return emitParenExpression(node); + case 213: case 173: - return emitDeleteExpression(node); case 174: - return emitTypeOfExpression(node); + return emitFunctionDeclaration(node); case 175: - return emitVoidExpression(node); + return emitDeleteExpression(node); case 176: - return emitAwaitExpression(node); + return emitTypeOfExpression(node); case 177: - return emitPrefixUnaryExpression(node); + return emitVoidExpression(node); case 178: - return emitPostfixUnaryExpression(node); + return emitAwaitExpression(node); case 179: - return emitBinaryExpression(node); + return emitPrefixUnaryExpression(node); case 180: + return emitPostfixUnaryExpression(node); + case 181: + return emitBinaryExpression(node); + case 182: return emitConditionalExpression(node); - case 183: + case 185: return emitSpreadElementExpression(node); - case 182: + case 184: return emitYieldExpression(node); - case 185: + case 187: return; - case 190: - case 217: + case 192: + case 219: return emitBlock(node); - case 191: + case 193: return emitVariableStatement(node); - case 192: + case 194: return write(";"); - case 193: + case 195: return emitExpressionStatement(node); - case 194: + case 196: return emitIfStatement(node); - case 195: + case 197: return emitDoStatement(node); - case 196: + case 198: return emitWhileStatement(node); - case 197: - return emitForStatement(node); case 199: - case 198: - return emitForInOrForOfStatement(node); - case 200: + return emitForStatement(node); case 201: - return emitBreakOrContinueStatement(node); + case 200: + return emitForInOrForOfStatement(node); case 202: - return emitReturnStatement(node); case 203: - return emitWithStatement(node); + return emitBreakOrContinueStatement(node); case 204: + return emitReturnStatement(node); + case 205: + return emitWithStatement(node); + case 206: return emitSwitchStatement(node); - case 239: - case 240: + case 241: + case 242: return emitCaseOrDefaultClause(node); - case 205: + case 207: return emitLabelledStatement(node); - case 206: + case 208: return emitThrowStatement(node); - case 207: + case 209: return emitTryStatement(node); - case 242: + case 244: return emitCatchClause(node); - case 208: + case 210: return emitDebuggerStatement(node); - case 209: + case 211: return emitVariableDeclaration(node); - case 184: + case 186: return emitClassExpression(node); - case 212: + case 214: return emitClassDeclaration(node); - case 213: - return emitInterfaceDeclaration(node); case 215: + return emitInterfaceDeclaration(node); + case 217: return emitEnumDeclaration(node); - case 245: + case 247: return emitEnumMember(node); - case 216: + case 218: return emitModuleDeclaration(node); - case 220: + case 222: return emitImportDeclaration(node); - case 219: + case 221: return emitImportEqualsDeclaration(node); - case 226: + case 228: return emitExportDeclaration(node); - case 225: + case 227: return emitExportAssignment(node); - case 246: + case 248: return emitSourceFileNode(node); } } @@ -29402,7 +30177,7 @@ var ts; } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 246 || node.pos !== node.parent.pos) { + if (node.parent.kind === 248 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { return getLeadingCommentsWithoutDetachedComments(); } @@ -29414,7 +30189,7 @@ var ts; } function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 246 || node.end !== node.parent.end) { + if (node.parent.kind === 248 || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -29516,6 +30291,7 @@ var ts; write(shebang); } } + var _a; } function emitFile(jsFilePath, sourceFile) { emitJavaScript(jsFilePath, sourceFile); @@ -29525,261 +30301,6 @@ var ts; } } ts.emitFiles = emitFiles; - var entities = { - "quot": 0x0022, - "amp": 0x0026, - "apos": 0x0027, - "lt": 0x003C, - "gt": 0x003E, - "nbsp": 0x00A0, - "iexcl": 0x00A1, - "cent": 0x00A2, - "pound": 0x00A3, - "curren": 0x00A4, - "yen": 0x00A5, - "brvbar": 0x00A6, - "sect": 0x00A7, - "uml": 0x00A8, - "copy": 0x00A9, - "ordf": 0x00AA, - "laquo": 0x00AB, - "not": 0x00AC, - "shy": 0x00AD, - "reg": 0x00AE, - "macr": 0x00AF, - "deg": 0x00B0, - "plusmn": 0x00B1, - "sup2": 0x00B2, - "sup3": 0x00B3, - "acute": 0x00B4, - "micro": 0x00B5, - "para": 0x00B6, - "middot": 0x00B7, - "cedil": 0x00B8, - "sup1": 0x00B9, - "ordm": 0x00BA, - "raquo": 0x00BB, - "frac14": 0x00BC, - "frac12": 0x00BD, - "frac34": 0x00BE, - "iquest": 0x00BF, - "Agrave": 0x00C0, - "Aacute": 0x00C1, - "Acirc": 0x00C2, - "Atilde": 0x00C3, - "Auml": 0x00C4, - "Aring": 0x00C5, - "AElig": 0x00C6, - "Ccedil": 0x00C7, - "Egrave": 0x00C8, - "Eacute": 0x00C9, - "Ecirc": 0x00CA, - "Euml": 0x00CB, - "Igrave": 0x00CC, - "Iacute": 0x00CD, - "Icirc": 0x00CE, - "Iuml": 0x00CF, - "ETH": 0x00D0, - "Ntilde": 0x00D1, - "Ograve": 0x00D2, - "Oacute": 0x00D3, - "Ocirc": 0x00D4, - "Otilde": 0x00D5, - "Ouml": 0x00D6, - "times": 0x00D7, - "Oslash": 0x00D8, - "Ugrave": 0x00D9, - "Uacute": 0x00DA, - "Ucirc": 0x00DB, - "Uuml": 0x00DC, - "Yacute": 0x00DD, - "THORN": 0x00DE, - "szlig": 0x00DF, - "agrave": 0x00E0, - "aacute": 0x00E1, - "acirc": 0x00E2, - "atilde": 0x00E3, - "auml": 0x00E4, - "aring": 0x00E5, - "aelig": 0x00E6, - "ccedil": 0x00E7, - "egrave": 0x00E8, - "eacute": 0x00E9, - "ecirc": 0x00EA, - "euml": 0x00EB, - "igrave": 0x00EC, - "iacute": 0x00ED, - "icirc": 0x00EE, - "iuml": 0x00EF, - "eth": 0x00F0, - "ntilde": 0x00F1, - "ograve": 0x00F2, - "oacute": 0x00F3, - "ocirc": 0x00F4, - "otilde": 0x00F5, - "ouml": 0x00F6, - "divide": 0x00F7, - "oslash": 0x00F8, - "ugrave": 0x00F9, - "uacute": 0x00FA, - "ucirc": 0x00FB, - "uuml": 0x00FC, - "yacute": 0x00FD, - "thorn": 0x00FE, - "yuml": 0x00FF, - "OElig": 0x0152, - "oelig": 0x0153, - "Scaron": 0x0160, - "scaron": 0x0161, - "Yuml": 0x0178, - "fnof": 0x0192, - "circ": 0x02C6, - "tilde": 0x02DC, - "Alpha": 0x0391, - "Beta": 0x0392, - "Gamma": 0x0393, - "Delta": 0x0394, - "Epsilon": 0x0395, - "Zeta": 0x0396, - "Eta": 0x0397, - "Theta": 0x0398, - "Iota": 0x0399, - "Kappa": 0x039A, - "Lambda": 0x039B, - "Mu": 0x039C, - "Nu": 0x039D, - "Xi": 0x039E, - "Omicron": 0x039F, - "Pi": 0x03A0, - "Rho": 0x03A1, - "Sigma": 0x03A3, - "Tau": 0x03A4, - "Upsilon": 0x03A5, - "Phi": 0x03A6, - "Chi": 0x03A7, - "Psi": 0x03A8, - "Omega": 0x03A9, - "alpha": 0x03B1, - "beta": 0x03B2, - "gamma": 0x03B3, - "delta": 0x03B4, - "epsilon": 0x03B5, - "zeta": 0x03B6, - "eta": 0x03B7, - "theta": 0x03B8, - "iota": 0x03B9, - "kappa": 0x03BA, - "lambda": 0x03BB, - "mu": 0x03BC, - "nu": 0x03BD, - "xi": 0x03BE, - "omicron": 0x03BF, - "pi": 0x03C0, - "rho": 0x03C1, - "sigmaf": 0x03C2, - "sigma": 0x03C3, - "tau": 0x03C4, - "upsilon": 0x03C5, - "phi": 0x03C6, - "chi": 0x03C7, - "psi": 0x03C8, - "omega": 0x03C9, - "thetasym": 0x03D1, - "upsih": 0x03D2, - "piv": 0x03D6, - "ensp": 0x2002, - "emsp": 0x2003, - "thinsp": 0x2009, - "zwnj": 0x200C, - "zwj": 0x200D, - "lrm": 0x200E, - "rlm": 0x200F, - "ndash": 0x2013, - "mdash": 0x2014, - "lsquo": 0x2018, - "rsquo": 0x2019, - "sbquo": 0x201A, - "ldquo": 0x201C, - "rdquo": 0x201D, - "bdquo": 0x201E, - "dagger": 0x2020, - "Dagger": 0x2021, - "bull": 0x2022, - "hellip": 0x2026, - "permil": 0x2030, - "prime": 0x2032, - "Prime": 0x2033, - "lsaquo": 0x2039, - "rsaquo": 0x203A, - "oline": 0x203E, - "frasl": 0x2044, - "euro": 0x20AC, - "image": 0x2111, - "weierp": 0x2118, - "real": 0x211C, - "trade": 0x2122, - "alefsym": 0x2135, - "larr": 0x2190, - "uarr": 0x2191, - "rarr": 0x2192, - "darr": 0x2193, - "harr": 0x2194, - "crarr": 0x21B5, - "lArr": 0x21D0, - "uArr": 0x21D1, - "rArr": 0x21D2, - "dArr": 0x21D3, - "hArr": 0x21D4, - "forall": 0x2200, - "part": 0x2202, - "exist": 0x2203, - "empty": 0x2205, - "nabla": 0x2207, - "isin": 0x2208, - "notin": 0x2209, - "ni": 0x220B, - "prod": 0x220F, - "sum": 0x2211, - "minus": 0x2212, - "lowast": 0x2217, - "radic": 0x221A, - "prop": 0x221D, - "infin": 0x221E, - "ang": 0x2220, - "and": 0x2227, - "or": 0x2228, - "cap": 0x2229, - "cup": 0x222A, - "int": 0x222B, - "there4": 0x2234, - "sim": 0x223C, - "cong": 0x2245, - "asymp": 0x2248, - "ne": 0x2260, - "equiv": 0x2261, - "le": 0x2264, - "ge": 0x2265, - "sub": 0x2282, - "sup": 0x2283, - "nsub": 0x2284, - "sube": 0x2286, - "supe": 0x2287, - "oplus": 0x2295, - "otimes": 0x2297, - "perp": 0x22A5, - "sdot": 0x22C5, - "lceil": 0x2308, - "rceil": 0x2309, - "lfloor": 0x230A, - "rfloor": 0x230B, - "lang": 0x2329, - "rang": 0x232A, - "loz": 0x25CA, - "spades": 0x2660, - "clubs": 0x2663, - "hearts": 0x2665, - "diams": 0x2666 - }; })(ts || (ts = {})); var ts; (function (ts) { @@ -29826,11 +30347,11 @@ var ts; if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { var failedLookupLocations = []; var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolvedFileName = loadNodeModuleFromFile(candidate, false, failedLookupLocations, host); + var resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (resolvedFileName) { return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; } - resolvedFileName = loadNodeModuleFromDirectory(candidate, false, failedLookupLocations, host); + resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); return resolvedFileName ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; @@ -29840,13 +30361,8 @@ var ts; } } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { - if (loadOnlyDts) { - return tryLoad(".d.ts"); - } - else { - return ts.forEach(ts.supportedExtensions, tryLoad); - } + function loadNodeModuleFromFile(candidate, failedLookupLocation, host) { + return ts.forEach(ts.supportedJsExtensions, tryLoad); function tryLoad(ext) { var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; if (host.fileExists(fileName)) { @@ -29858,7 +30374,7 @@ var ts; } } } - function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + function loadNodeModuleFromDirectory(candidate, failedLookupLocation, host) { var packageJsonPath = ts.combinePaths(candidate, "package.json"); if (host.fileExists(packageJsonPath)) { var jsonContent; @@ -29870,7 +30386,7 @@ var ts; jsonContent = { typings: undefined }; } if (jsonContent.typings) { - var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); if (result) { return result; } @@ -29879,7 +30395,7 @@ var ts; else { failedLookupLocation.push(packageJsonPath); } - return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), failedLookupLocation, host); } function loadModuleFromNodeModules(moduleName, directory, host) { var failedLookupLocations = []; @@ -29889,11 +30405,11 @@ var ts; if (baseName !== "node_modules") { var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var result = loadNodeModuleFromFile(candidate, true, failedLookupLocations, host); + var result = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; } - result = loadNodeModuleFromDirectory(candidate, true, failedLookupLocations, host); + result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; } @@ -29911,16 +30427,17 @@ var ts; return i === 0 || (i === 1 && name.charCodeAt(0) === 46); } function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - if (moduleName.indexOf('!') != -1) { + if (moduleName.indexOf("!") != -1) { return { resolvedModule: undefined, failedLookupLocations: [] }; } var searchPath = ts.getDirectoryPath(containingFile); var searchName; var failedLookupLocations = []; var referencedSourceFile; + var extensions = compilerOptions.allowNonTsExtensions ? ts.supportedJsExtensions : ts.supportedExtensions; while (true) { searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + referencedSourceFile = ts.forEach(extensions, function (extension) { if (extension === ".tsx" && !compilerOptions.jsx) { return undefined; } @@ -30220,7 +30737,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - return filesByName.get(fileName); + return filesByName.get(fileName) || filesByName.get(ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory())); } function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { @@ -30306,13 +30823,18 @@ var ts; if (file.imports) { return; } + var isJavaScriptFile = ts.isSourceFileJavaScript(file); var imports; for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var node = _a[_i]; + collect(node, true); + } + file.imports = imports || emptyArray; + function collect(node, allowRelativeModuleNames) { switch (node.kind) { - case 220: - case 219: - case 226: + case 222: + case 221: + case 228: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -30320,24 +30842,35 @@ var ts; if (!moduleNameExpr.text) { break; } - (imports || (imports = [])).push(moduleNameExpr); + if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { + (imports || (imports = [])).push(moduleNameExpr); + } break; - case 216: - if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { - ts.forEachChild(node.body, function (node) { - if (ts.isExternalModuleImportEqualsDeclaration(node) && - ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9) { - var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); - if (moduleName) { - (imports || (imports = [])).push(moduleName); + case 168: + if (isJavaScriptFile && ts.isRequireCall(node)) { + var jsImports = node.arguments; + if (jsImports) { + imports = (imports || []); + for (var i = 0; i < jsImports.length; i++) { + if (jsImports[i].kind === 9) { + imports.push(jsImports[i]); } } + } + } + break; + case 218: + if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { + ts.forEachChild(node.body, function (node) { + collect(node, false); }); } break; } + if (ts.isSourceFileJavaScript(file)) { + ts.forEachChild(node, function (node) { return collect(node, allowRelativeModuleNames); }); + } } - file.imports = imports || emptyArray; } function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; @@ -30380,48 +30913,46 @@ var ts; } } function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - if (filesByName.contains(canonicalName)) { - return getSourceFileFromCache(fileName, canonicalName, false); + if (filesByName.contains(fileName)) { + return getSourceFileFromCache(fileName, false); } - else { - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); - var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); - if (filesByName.contains(canonicalAbsolutePath)) { - return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); + var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); + if (filesByName.contains(normalizedAbsolutePath)) { + var file_1 = getSourceFileFromCache(normalizedAbsolutePath, true); + filesByName.set(fileName, file_1); + return file_1; + } + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }); - filesByName.set(canonicalName, file); - if (file) { - skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - filesByName.set(canonicalAbsolutePath, file); - var basePath = ts.getDirectoryPath(fileName); - if (!options.noResolve) { - processReferencedFiles(file, basePath); - } - processImportedModules(file, basePath); - if (isDefaultLib) { - file.isDefaultLib = true; - files.unshift(file); - } - else { - files.push(file); - } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + }); + filesByName.set(fileName, file); + if (file) { + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + filesByName.set(normalizedAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); + if (!options.noResolve) { + processReferencedFiles(file, basePath); + } + processImportedModules(file, basePath); + if (isDefaultLib) { + file.isDefaultLib = true; + files.unshift(file); + } + else { + files.push(file); } - return file; } - function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) { - var file = filesByName.get(canonicalName); + return file; + function getSourceFileFromCache(fileName, useAbsolutePath) { + var file = filesByName.get(fileName); if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; - if (canonicalName !== sourceFileName) { + if (ts.normalizeSlashes(fileName) !== ts.normalizeSlashes(sourceFileName)) { if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); } @@ -30582,8 +31113,8 @@ var ts; var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } - if (options.module && languageVersion >= 2) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); + if (options.module === 5 && languageVersion < 2) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower)); } if (options.outDir || options.sourceRoot || @@ -30617,10 +31148,6 @@ var ts; !options.experimentalDecorators) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } - if (options.experimentalAsyncFunctions && - options.target !== 2) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); - } } } ts.createProgram = createProgram; @@ -30663,98 +31190,98 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 195) { + if (node.parent.kind === 197) { return spanInPreviousNode(node); } - if (node.parent.kind === 197) { + if (node.parent.kind === 199) { return textSpan(node); } - if (node.parent.kind === 179 && node.parent.operatorToken.kind === 24) { + if (node.parent.kind === 181 && node.parent.operatorToken.kind === 24) { return textSpan(node); } - if (node.parent.kind === 172 && node.parent.body === node) { + if (node.parent.kind === 174 && node.parent.body === node) { return textSpan(node); } } switch (node.kind) { - case 191: + case 193: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 209: - case 139: - case 138: - return spanInVariableDeclaration(node); - case 136: - return spanInParameterDeclaration(node); case 211: case 141: case 140: + return spanInVariableDeclaration(node); + case 138: + return spanInParameterDeclaration(node); + case 213: case 143: - case 144: case 142: - case 171: - case 172: + case 145: + case 146: + case 144: + case 173: + case 174: return spanInFunctionDeclaration(node); - case 190: + case 192: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 217: + case 219: return spanInBlock(node); - case 242: + case 244: return spanInBlock(node.block); - case 193: + case 195: return textSpan(node.expression); - case 202: + case 204: return textSpan(node.getChildAt(0), node.expression); - case 196: + case 198: return textSpan(node, ts.findNextToken(node.expression, node)); - case 195: + case 197: return spanInNode(node.statement); - case 208: + case 210: return textSpan(node.getChildAt(0)); - case 194: + case 196: return textSpan(node, ts.findNextToken(node.expression, node)); - case 205: + case 207: return spanInNode(node.statement); - case 201: - case 200: + case 203: + case 202: return textSpan(node.getChildAt(0), node.label); - case 197: - return spanInForStatement(node); - case 198: case 199: + return spanInForStatement(node); + case 200: + case 201: return textSpan(node, ts.findNextToken(node.expression, node)); - case 204: + case 206: return textSpan(node, ts.findNextToken(node.expression, node)); - case 239: - case 240: + case 241: + case 242: return spanInNode(node.statements[0]); - case 207: + case 209: return spanInBlock(node.tryBlock); - case 206: + case 208: return textSpan(node, node.expression); - case 225: + case 227: return textSpan(node, node.expression); - case 219: + case 221: return textSpan(node, node.moduleReference); - case 220: + case 222: return textSpan(node, node.moduleSpecifier); - case 226: + case 228: return textSpan(node, node.moduleSpecifier); - case 216: + case 218: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 212: - case 215: - case 245: - case 166: - case 167: + case 214: + case 217: + case 247: + case 168: + case 169: return textSpan(node); - case 203: + case 205: return spanInNode(node.statement); - case 213: - case 214: + case 215: + case 216: return undefined; case 23: case 1: @@ -30769,22 +31296,22 @@ var ts; return spanInOpenParenToken(node); case 18: return spanInCloseParenToken(node); - case 53: + case 54: return spanInColonToken(node); case 27: case 25: return spanInGreaterThanOrLessThanToken(node); - case 102: + case 104: return spanInWhileKeyword(node); - case 78: - case 70: - case 83: + case 80: + case 72: + case 85: return spanInNextNode(node); default: - if (node.parent.kind === 243 && node.parent.name === node) { + if (node.parent.kind === 245 && node.parent.name === node) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 169 && node.parent.type === node) { + if (node.parent.kind === 171 && node.parent.type === node) { return spanInNode(node.parent.expression); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { @@ -30794,12 +31321,12 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 198 || - variableDeclaration.parent.parent.kind === 199) { + if (variableDeclaration.parent.parent.kind === 200 || + variableDeclaration.parent.parent.kind === 201) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 191; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 197 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 193; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 199 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -30845,7 +31372,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1) || - (functionDeclaration.parent.kind === 212 && functionDeclaration.kind !== 142); + (functionDeclaration.parent.kind === 214 && functionDeclaration.kind !== 144); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -30865,23 +31392,23 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 216: + case 218: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 196: - case 194: case 198: - case 199: + case 196: + case 200: + case 201: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - case 197: + case 199: 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 === 210) { + if (forStatement.initializer.kind === 212) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -30900,34 +31427,34 @@ var ts; } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 215: + case 217: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 212: + case 214: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 218: + case 220: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 217: + case 219: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 215: - case 212: + case 217: + case 214: return textSpan(node); - case 190: + case 192: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 242: + case 244: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 218: + case 220: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { @@ -30939,24 +31466,24 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 195) { + if (node.parent.kind === 197) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 171: - case 211: - case 172: - case 141: - case 140: + case 173: + case 213: + case 174: case 143: - case 144: case 142: - case 196: - case 195: + case 145: + case 146: + case 144: + case 198: case 197: + case 199: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -30964,19 +31491,19 @@ var ts; return spanInNode(node.parent); } function spanInColonToken(node) { - if (ts.isFunctionLike(node.parent) || node.parent.kind === 243) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 245) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 169) { + if (node.parent.kind === 171) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 195) { + if (node.parent.kind === 197) { return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } return spanInNode(node.parent); @@ -31054,7 +31581,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 172; + return ts.isFunctionBlock(node) && node.parent.kind !== 174; } var depth = 0; var maxDepth = 20; @@ -31066,30 +31593,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 190: + case 192: if (!ts.isFunctionBlock(n)) { var parent_7 = n.parent; var openBrace = ts.findChildOfKind(n, 15, sourceFile); var closeBrace = ts.findChildOfKind(n, 16, sourceFile); - if (parent_7.kind === 195 || - parent_7.kind === 198 || + if (parent_7.kind === 197 || + parent_7.kind === 200 || + parent_7.kind === 201 || parent_7.kind === 199 || - parent_7.kind === 197 || - parent_7.kind === 194 || parent_7.kind === 196 || - parent_7.kind === 203 || - parent_7.kind === 242) { + parent_7.kind === 198 || + parent_7.kind === 205 || + parent_7.kind === 244) { addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_7.kind === 207) { + if (parent_7.kind === 209) { var tryStatement = parent_7; if (tryStatement.tryBlock === n) { addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 83, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 85, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -31105,23 +31632,23 @@ var ts; }); break; } - case 217: { + case 219: { var openBrace = ts.findChildOfKind(n, 15, sourceFile); var closeBrace = ts.findChildOfKind(n, 16, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 212: - case 213: + case 214: case 215: - case 163: - case 218: { + case 217: + case 165: + case 220: { var openBrace = ts.findChildOfKind(n, 15, sourceFile); var closeBrace = ts.findChildOfKind(n, 16, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 162: + case 164: var openBracket = ts.findChildOfKind(n, 19, sourceFile); var closeBracket = ts.findChildOfKind(n, 20, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -31147,10 +31674,10 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_28 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_28); + for (var name_29 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_29); if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_28); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_29); if (!matches) { continue; } @@ -31161,14 +31688,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_28); + matches = patternMatcher.getMatches(containers, name_29); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_28, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_29, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -31191,7 +31718,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 67 || + if (node.kind === 69 || node.kind === 9 || node.kind === 8) { return node.text; @@ -31205,7 +31732,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 134) { + else if (declaration.name.kind === 136) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -31222,7 +31749,7 @@ var ts; } return true; } - if (expression.kind === 164) { + if (expression.kind === 166) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -31233,7 +31760,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 134) { + if (declaration.name.kind === 136) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -31296,14 +31823,14 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 216: + case 218: do { current = current.parent; - } while (current.kind === 216); - case 212: + } while (current.kind === 218); + case 214: + case 217: case 215: case 213: - case 211: indent++; } current = current.parent; @@ -31314,26 +31841,26 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 191: + case 193: ts.forEach(node.declarationList.declarations, visit); break; - case 159: - case 160: + case 161: + case 162: ts.forEach(node.elements, visit); break; - case 226: + case 228: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 220: + case 222: var importClause = node.importClause; if (importClause) { if (importClause.name) { childNodes.push(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222) { + if (importClause.namedBindings.kind === 224) { childNodes.push(importClause.namedBindings); } else { @@ -31342,20 +31869,20 @@ var ts; } } break; - case 161: - case 209: + case 163: + case 211: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } - case 212: + case 214: + case 217: case 215: + case 218: case 213: - case 216: - case 211: - case 219: - case 224: - case 228: + case 221: + case 226: + case 230: childNodes.push(node); break; } @@ -31390,17 +31917,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 212: + case 214: + case 217: case 215: - case 213: topLevelNodes.push(node); break; - case 216: + case 218: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 211: + case 213: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -31411,9 +31938,9 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 211) { - if (functionDeclaration.body && functionDeclaration.body.kind === 190) { - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 211 && !isEmpty(s.name.text); })) { + if (functionDeclaration.kind === 213) { + if (functionDeclaration.body && functionDeclaration.body.kind === 192) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 213 && !isEmpty(s.name.text); })) { return true; } if (!ts.isFunctionBlock(functionDeclaration.parent)) { @@ -31466,7 +31993,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 136: + case 138: if (ts.isBindingPattern(node.name)) { break; } @@ -31474,34 +32001,34 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 141: - case 140: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); case 143: + case 142: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); + case 145: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 144: + case 146: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 147: + case 149: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 245: + case 247: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 145: + case 147: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 146: + case 148: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 139: - case 138: + case 141: + case 140: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 211: + case 213: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 209: - case 161: + case 211: + case 163: var variableDeclarationNode; - var name_29; - if (node.kind === 161) { - name_29 = node.name; + var name_30; + if (node.kind === 163) { + name_30 = node.name; variableDeclarationNode = node; - while (variableDeclarationNode && variableDeclarationNode.kind !== 209) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 211) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -31509,24 +32036,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_29 = node.name; + name_30 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.variableElement); } - case 142: + case 144: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 228: - case 224: - case 219: + case 230: + case 226: case 221: - case 222: + case 223: + case 224: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -31556,17 +32083,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 246: + case 248: return createSourceFileItem(node); - case 212: + case 214: return createClassItem(node); - case 215: + case 217: return createEnumItem(node); - case 213: + case 215: return createIterfaceItem(node); - case 216: + case 218: return createModuleItem(node); - case 211: + case 213: return createFunctionItem(node); } return undefined; @@ -31576,7 +32103,7 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 216) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 218) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -31588,7 +32115,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.body && node.body.kind === 190) { + if (node.body && node.body.kind === 192) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -31609,7 +32136,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 142 && member; + return member.kind === 144 && member; }); var nodes = removeDynamicallyNamedProperties(node); if (constructor) { @@ -31630,19 +32157,19 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 134; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 136; }); } function removeDynamicallyNamedProperties(node) { return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 216) { + while (node.body.kind === 218) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 246 + return node.kind === 248 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -32125,21 +32652,21 @@ var ts; var resolvedSignature = typeChecker.getResolvedSignature(call, candidates); cancellationToken.throwIfCancellationRequested(); if (!candidates.length) { - if (ts.isJavaScript(sourceFile.fileName)) { + if (ts.isSourceFileJavaScript(sourceFile)) { return createJavaScriptSignatureHelpItems(argumentInfo); } return undefined; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 166) { + if (argumentInfo.invocation.kind !== 168) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 67 + var name = expression.kind === 69 ? expression - : expression.kind === 164 + : expression.kind === 166 ? expression.name : undefined; if (!name || !name.text) { @@ -32168,7 +32695,7 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 166 || node.parent.kind === 167) { + if (node.parent.kind === 168 || node.parent.kind === 169) { var callExpression = node.parent; if (node.kind === 25 || node.kind === 17) { @@ -32199,23 +32726,23 @@ var ts; }; } } - else if (node.kind === 11 && node.parent.kind === 168) { + else if (node.kind === 11 && node.parent.kind === 170) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 12 && node.parent.parent.kind === 168) { + else if (node.kind === 12 && node.parent.parent.kind === 170) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 181); + ts.Debug.assert(templateExpression.kind === 183); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 188 && node.parent.parent.parent.kind === 168) { + else if (node.parent.kind === 190 && node.parent.parent.parent.kind === 170) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 181); + ts.Debug.assert(templateExpression.kind === 183); if (node.kind === 14 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } @@ -32279,7 +32806,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 181) { + if (template.kind === 183) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -32288,7 +32815,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 246; n = n.parent) { + for (var n = node; n.kind !== 248; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -32468,39 +32995,39 @@ var ts; return false; } switch (n.kind) { - case 212: - case 213: + case 214: case 215: - case 163: - case 159: - case 153: - case 190: case 217: - case 218: + case 165: + case 161: + case 155: + case 192: + case 219: + case 220: return nodeEndsWith(n, 16, sourceFile); - case 242: + case 244: return isCompletedNode(n.block, sourceFile); - case 167: + case 169: if (!n.arguments) { return true; } - case 166: - case 170: - case 158: + case 168: + case 172: + case 160: return nodeEndsWith(n, 18, sourceFile); - case 150: - case 151: + case 152: + case 153: return isCompletedNode(n.type, sourceFile); - case 142: - case 143: case 144: - case 211: - case 171: - case 141: - case 140: - case 146: case 145: - case 172: + case 146: + case 213: + case 173: + case 143: + case 142: + case 148: + case 147: + case 174: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -32508,61 +33035,62 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 18, sourceFile); - case 216: + case 218: return n.body && isCompletedNode(n.body, sourceFile); - case 194: + case 196: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 193: - return isCompletedNode(n.expression, sourceFile); + case 195: + return isCompletedNode(n.expression, sourceFile) || + hasChildOfKind(n, 23); + case 164: case 162: - case 160: - case 165: - case 134: - case 155: + case 167: + case 136: + case 157: return nodeEndsWith(n, 20, sourceFile); - case 147: + case 149: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 20, sourceFile); - case 239: - case 240: + case 241: + case 242: return false; - case 197: - case 198: case 199: - case 196: + case 200: + case 201: + case 198: return isCompletedNode(n.statement, sourceFile); - case 195: - var hasWhileKeyword = findChildOfKind(n, 102, sourceFile); + case 197: + var hasWhileKeyword = findChildOfKind(n, 104, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 18, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 152: + case 154: return isCompletedNode(n.exprName, sourceFile); - case 174: - case 173: + case 176: case 175: - case 182: - case 183: + case 177: + case 184: + case 185: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 168: + case 170: return isCompletedNode(n.template, sourceFile); - case 181: + case 183: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 188: + case 190: return ts.nodeIsPresent(n.literal); - case 177: - return isCompletedNode(n.operand, sourceFile); case 179: + return isCompletedNode(n.operand, sourceFile); + case 181: return isCompletedNode(n.right, sourceFile); - case 180: + case 182: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -32605,7 +33133,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 269 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 271 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -32685,7 +33213,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n) || n.kind === 234) { + if (isToken(n) || n.kind === 236) { return n; } var children = n.getChildren(); @@ -32693,16 +33221,16 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n) || n.kind === 234) { + if (isToken(n) || n.kind === 236) { return n; } var children = n.getChildren(); for (var i = 0, len = children.length; i < len; i++) { var child = children[i]; - if (position < child.end && (nodeHasTokens(child) || child.kind === 234)) { + if (position < child.end && (nodeHasTokens(child) || child.kind === 236)) { var start = child.getStart(sourceFile); var lookInPreviousChild = (start >= position) || - (child.kind === 234 && start === child.end); + (child.kind === 236 && start === child.end); if (lookInPreviousChild) { var candidate = findRightmostChildNodeWithTokens(children, i); return candidate && findRightmostToken(candidate); @@ -32712,7 +33240,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 246); + ts.Debug.assert(startNode !== undefined || n.kind === 248); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -32764,9 +33292,9 @@ var ts; var node = ts.getTokenAtPosition(sourceFile, position); if (isToken(node)) { switch (node.kind) { - case 100: - case 106: - case 72: + case 102: + case 108: + case 74: node = node.parent === undefined ? undefined : node.parent.parent; break; default: @@ -32812,21 +33340,21 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 149 || node.kind === 166) { + if (node.kind === 151 || node.kind === 168) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 212 || node.kind === 213) { + if (ts.isFunctionLike(node) || node.kind === 214 || node.kind === 215) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 132; + return n.kind >= 0 && n.kind <= 134; } ts.isToken = isToken; function isWord(kind) { - return kind === 67 || ts.isKeyword(kind); + return kind === 69 || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { @@ -32836,8 +33364,17 @@ var ts; return kind === 2 || kind === 3; } ts.isComment = isComment; + function isStringOrRegularExpressionOrTemplateLiteral(kind) { + if (kind === 9 + || kind === 10 + || ts.isTemplateLiteralKind(kind)) { + return true; + } + return false; + } + ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 15 <= kind && kind <= 66; + return 15 <= kind && kind <= 68; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -32847,9 +33384,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { + case 112: case 110: - case 108: - case 109: + case 111: return true; } return false; @@ -32875,7 +33412,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 136; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 138; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -32897,7 +33434,8 @@ var ts; increaseIndent: function () { indent++; }, decreaseIndent: function () { indent--; }, clear: resetWriter, - trackSymbol: function () { } + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } }; function writeIndent() { if (lineStart) { @@ -33055,7 +33593,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 224 || location.parent.kind === 228) && + (location.parent.kind === 226 || location.parent.kind === 230) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -33075,8 +33613,12 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var scanner = ts.createScanner(2, false); + var standardScanner = ts.createScanner(2, false, 0); + var jsxScanner = ts.createScanner(2, false, 1); + var scanner; function getFormattingScanner(sourceFile, startPos, endPos) { + ts.Debug.assert(scanner === undefined); + scanner = sourceFile.languageVariant === 1 ? jsxScanner : standardScanner; scanner.setText(sourceFile.text); scanner.setTextPos(startPos); var wasNewLine = true; @@ -33091,11 +33633,14 @@ var ts; isOnToken: isOnToken, lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, close: function () { + ts.Debug.assert(scanner !== undefined); lastTokenInfo = undefined; scanner.setText(undefined); + scanner = undefined; } }; function advance() { + ts.Debug.assert(scanner !== undefined); lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { @@ -33137,10 +33682,10 @@ var ts; if (node) { switch (node.kind) { case 29: - case 62: - case 63: + case 64: + case 65: + case 45: case 44: - case 43: return true; } } @@ -33149,11 +33694,11 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 236: - case 233: + case 238: case 235: - case 232: - return node.kind === 67; + case 237: + case 234: + return node.kind === 69; } } return false; @@ -33166,9 +33711,10 @@ var ts; container.kind === 14; } function startsWithSlashToken(t) { - return t === 38 || t === 59; + return t === 39 || t === 61; } function readTokenInfo(n) { + ts.Debug.assert(scanner !== undefined); if (!isOnToken()) { return { leadingTrivia: leadingTrivia, @@ -33208,7 +33754,7 @@ var ts; currentToken = scanner.reScanTemplateToken(); lastScanAction = 3; } - else if (expectedScanAction === 4 && currentToken === 67) { + else if (expectedScanAction === 4 && currentToken === 69) { currentToken = scanner.scanJsxIdentifier(); lastScanAction = 4; } @@ -33250,6 +33796,7 @@ var ts; return fixTokenKind(lastTokenInfo, n); } function isOnToken() { + ts.Debug.assert(scanner !== undefined); var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); return startPos < endPos && current !== 1 && !ts.isTrivia(current); @@ -33462,15 +34009,15 @@ var ts; 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, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16, 78), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16, 102), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16, 80), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16, 104), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.FromTokens([18, 20, 24, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); @@ -33478,9 +34025,9 @@ var ts; this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67, 3, 71]); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69, 3, 73]); this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18, 3, 77, 98, 83, 78]); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18, 3, 79, 100, 85, 80]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, 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, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); @@ -33488,37 +34035,37 @@ var ts; this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(40, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(41, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100, 96, 90, 76, 92, 99, 117]), 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([106, 72]), 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([102, 98, 92, 78, 94, 101, 119]), 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([108, 74]), 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, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(87, 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, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(101, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(92, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18, 77, 78, 69]), 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([98, 83]), 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([121, 127]), 67), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18, 79, 80, 71]), 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([100, 85]), 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123, 129]), 69), 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(119, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123, 125]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113, 71, 120, 75, 79, 80, 81, 121, 104, 87, 105, 123, 124, 108, 110, 109, 127, 111, 130]), 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([81, 104])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125, 127]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115, 73, 122, 77, 81, 82, 83, 123, 106, 89, 107, 125, 126, 110, 112, 111, 129, 113, 132]), 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([83, 106])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22, 67), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.FromTokens([18, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22, 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.FromTokens([18, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); @@ -33526,15 +34073,18 @@ var ts; this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.FromTokens([17, 19, 27, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeAssertionContext), 8)); this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8)); - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([113, 67, 80, 75, 71, 111, 110, 108, 109, 121, 127, 19, 37])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(85, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37, formatting.Shared.TokenRange.FromTokens([67, 17])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112, 37]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116, 85), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([115, 69, 82, 77, 73, 113, 112, 110, 111, 123, 129, 19, 37])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(87, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37, formatting.Shared.TokenRange.FromTokens([69, 17])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114, 37]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118, 87), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12, 13]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13, 14])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -33560,8 +34110,8 @@ var ts; this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, - this.SpaceBetweenAsyncAndFunctionKeyword, - this.SpaceBetweenTagAndTemplateString, + this.SpaceBetweenAsyncAndOpenParen, this.SpaceBetweenAsyncAndFunctionKeyword, + this.SpaceBetweenTagAndTemplateString, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail, this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, this.SpaceAfterModuleName, @@ -33613,46 +34163,46 @@ var ts; this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_30 in o) { - if (o[name_30] === rule) { - return name_30; + for (var name_31 in o) { + if (o[name_31] === rule) { + return name_31; } } throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 197; + return context.contextNode.kind === 199; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 179: - case 180: - case 187: - case 148: - case 156: - case 157: + case 181: + case 182: + case 189: + case 150: + case 158: + case 159: return true; - case 161: - case 214: - case 219: - case 209: - case 136: - case 245: - case 139: + case 163: + case 216: + case 221: + case 211: case 138: - return context.currentTokenSpan.kind === 55 || context.nextTokenSpan.kind === 55; - case 198: - return context.currentTokenSpan.kind === 88 || context.nextTokenSpan.kind === 88; - case 199: - return context.currentTokenSpan.kind === 132 || context.nextTokenSpan.kind === 132; + case 247: + case 141: + case 140: + return context.currentTokenSpan.kind === 56 || context.nextTokenSpan.kind === 56; + case 200: + return context.currentTokenSpan.kind === 90 || context.nextTokenSpan.kind === 90; + case 201: + return context.currentTokenSpan.kind === 134 || context.nextTokenSpan.kind === 134; } return false; }; @@ -33660,7 +34210,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 180; + return context.contextNode.kind === 182; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); @@ -33685,86 +34235,86 @@ var ts; return true; } switch (node.kind) { - case 190: - case 218: - case 163: - case 217: + case 192: + case 220: + case 165: + case 219: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 211: - case 141: - case 140: + case 213: case 143: - case 144: - case 145: - case 171: case 142: - case 172: - case 213: + case 145: + case 146: + case 147: + case 173: + case 144: + case 174: + case 215: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 211 || context.contextNode.kind === 171; + return context.contextNode.kind === 213 || context.contextNode.kind === 173; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 212: - case 184: - case 213: + case 214: + case 186: case 215: - case 153: - case 216: + case 217: + case 155: + case 218: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 212: - case 216: - case 215: - case 190: - case 242: + case 214: + case 218: case 217: - case 204: + case 192: + case 244: + case 219: + case 206: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 194: - case 204: - case 197: - case 198: - case 199: case 196: - case 207: - case 195: - case 203: - case 242: + case 206: + case 199: + case 200: + case 201: + case 198: + case 209: + case 197: + case 205: + case 244: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 163; + return context.contextNode.kind === 165; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 166; + return context.contextNode.kind === 168; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 167; + return context.contextNode.kind === 169; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -33772,6 +34322,9 @@ var ts; Rules.IsPreviousTokenNotComma = function (context) { return context.currentTokenSpan.kind !== 24; }; + Rules.IsArrowFunctionContext = function (context) { + return context.contextNode.kind === 174; + }; Rules.IsSameLineTokenContext = function (context) { return context.TokensAreOnSameLine(); }; @@ -33788,41 +34341,41 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 137; + return node.kind === 139; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 210 && + return context.currentTokenParent.kind === 212 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 216; + return context.contextNode.kind === 218; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 153; + return context.contextNode.kind === 155; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 25 && token.kind !== 27) { return false; } switch (parent.kind) { - case 149: - case 169: - case 212: - case 184: - case 213: - case 211: + case 151: case 171: - case 172: - case 141: - case 140: - case 145: - case 146: - case 166: - case 167: + case 214: case 186: + case 215: + case 213: + case 173: + case 174: + case 143: + case 142: + case 147: + case 148: + case 168: + case 169: + case 188: return true; default: return false; @@ -33833,13 +34386,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 169; + return context.contextNode.kind === 171; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 101 && context.currentTokenParent.kind === 175; + return context.currentTokenSpan.kind === 103 && context.currentTokenParent.kind === 177; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 182 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 184 && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -33861,7 +34414,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 132 + 1; + this.mapRowLength = 134 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -34037,7 +34590,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 132; token++) { + for (var token = 0; token <= 134; token++) { result.push(token); } return result; @@ -34079,17 +34632,17 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(68, 132); - TokenRange.BinaryOperators = TokenRange.FromRange(25, 66); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([88, 89, 132, 114, 122]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([40, 41, 49, 48]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 67, 17, 19, 15, 95, 90]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([67, 17, 95, 90]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([67, 18, 20, 90]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([67, 17, 95, 90]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([67, 18, 20, 90]); + TokenRange.Keywords = TokenRange.FromRange(70, 134); + TokenRange.BinaryOperators = TokenRange.FromRange(25, 68); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90, 91, 134, 116, 124]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41, 42, 50, 49]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 69, 17, 19, 15, 97, 92]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69, 17, 97, 92]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([69, 18, 20, 92]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([69, 17, 97, 92]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([69, 18, 20, 92]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([67, 126, 128, 118, 129, 101, 115]); + TokenRange.TypeNames = TokenRange.FromTokens([69, 128, 130, 120, 131, 103, 117]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -34260,17 +34813,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 212: - case 213: + case 214: + case 215: return ts.rangeContainsRange(parent.members, node); - case 216: + case 218: var body = parent.body; - return body && body.kind === 190 && ts.rangeContainsRange(body.statements, node); - case 246: - case 190: - case 217: + return body && body.kind === 192 && ts.rangeContainsRange(body.statements, node); + case 248: + case 192: + case 219: return ts.rangeContainsRange(parent.statements, node); - case 242: + case 244: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -34395,9 +34948,9 @@ var ts; if (indentation === -1) { if (isSomeBlock(node.kind)) { if (isSomeBlock(parent.kind) || - parent.kind === 246 || - parent.kind === 239 || - parent.kind === 240) { + parent.kind === 248 || + parent.kind === 241 || + parent.kind === 242) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -34430,18 +34983,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 212: return 71; - case 213: return 105; - case 211: return 85; - case 215: return 215; - case 143: return 121; - case 144: return 127; - case 141: + case 214: return 73; + case 215: return 107; + case 213: return 87; + case 217: return 217; + case 145: return 123; + case 146: return 129; + case 143: if (node.asteriskToken) { return 37; } - case 139: - case 136: + case 141: + case 138: return node.name.kind; } } @@ -34469,9 +35022,9 @@ var ts; case 20: case 17: case 18: - case 78: - case 102: - case 54: + case 80: + case 104: + case 55: return indentation; default: return nodeStartLine !== line ? indentation + delta : indentation; @@ -34551,7 +35104,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 137 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 139 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -34783,7 +35336,7 @@ var ts; for (var line = line1; line < line2; ++line) { var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile); var lineEndPosition = ts.getEndLinePosition(line, sourceFile); - if (range && ts.isComment(range.kind) && range.pos <= lineEndPosition && range.end > lineEndPosition) { + if (range && (ts.isComment(range.kind) || ts.isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) { continue; } var pos = lineEndPosition; @@ -34842,20 +35395,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 190: - case 217: + case 192: + case 219: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { + case 144: + case 213: + case 173: + case 143: case 142: - case 211: - case 171: - case 141: - case 140: - case 172: + case 174: if (node.typeParameters === list) { return 25; } @@ -34863,8 +35416,8 @@ var ts; return 17; } break; - case 166: - case 167: + case 168: + case 169: if (node.typeArguments === list) { return 25; } @@ -34872,7 +35425,7 @@ var ts; return 17; } break; - case 149: + case 151: if (node.typeArguments === list) { return 25; } @@ -34949,21 +35502,31 @@ var ts; if (position > sourceFile.text.length) { return 0; } + if (options.IndentStyle === ts.IndentStyle.None) { + return 0; + } var precedingToken = ts.findPrecedingToken(position, sourceFile); if (!precedingToken) { return 0; } - var precedingTokenIsLiteral = precedingToken.kind === 9 || - precedingToken.kind === 10 || - precedingToken.kind === 11 || - precedingToken.kind === 12 || - precedingToken.kind === 13 || - precedingToken.kind === 14; + var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 24 && precedingToken.parent.kind !== 179) { + if (options.IndentStyle === ts.IndentStyle.Block) { + var current_1 = position; + while (current_1 > 0) { + var char = sourceFile.text.charCodeAt(current_1); + if (!ts.isWhiteSpace(char) && !ts.isLineBreak(char)) { + break; + } + current_1--; + } + var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); + return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); + } + if (precedingToken.kind === 24 && precedingToken.parent.kind !== 181) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -35061,7 +35624,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 246 || !parentAndChildShareLine); + (parent.kind === 248 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -35085,8 +35648,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 194 && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 78, sourceFile); + if (parent.kind === 196 && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 80, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -35097,23 +35660,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 149: + case 151: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 163: + case 165: return node.parent.properties; - case 162: + case 164: return node.parent.elements; - case 211: - case 171: - case 172: - case 141: - case 140: - case 145: - case 146: { + case 213: + case 173: + case 174: + case 143: + case 142: + case 147: + case 148: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -35124,8 +35687,8 @@ var ts; } break; } - case 167: - case 166: { + case 169: + case 168: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -35153,8 +35716,8 @@ var ts; if (node.kind === 18) { return -1; } - if (node.parent && (node.parent.kind === 166 || - node.parent.kind === 167) && + if (node.parent && (node.parent.kind === 168 || + node.parent.kind === 169) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -35172,10 +35735,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { + case 168: + case 169: case 166: case 167: - case 164: - case 165: node = node.expression; break; default: @@ -35230,42 +35793,43 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 212: - case 184: - case 213: - case 215: + case 195: case 214: - case 162: - case 190: + case 186: + case 215: case 217: - case 163: - case 153: - case 155: - case 218: - case 240: - case 239: - case 170: + case 216: case 164: + case 192: + case 219: + case 165: + case 155: + case 157: + case 220: + case 242: + case 241: + case 172: case 166: - case 167: - case 191: - case 209: - case 225: - case 202: - case 180: - case 160: - case 159: - case 231: - case 232: - case 140: - case 145: - case 146: - case 136: - case 150: - case 151: - case 158: case 168: - case 176: + case 169: + case 193: + case 211: + case 227: + case 204: + case 182: + case 162: + case 161: + case 233: + case 234: + case 142: + case 147: + case 148: + case 138: + case 152: + case 153: + case 160: + case 170: + case 178: return true; } return false; @@ -35275,20 +35839,20 @@ var ts; return true; } switch (parent) { - case 195: - case 196: + case 197: case 198: + case 200: + case 201: case 199: - case 197: - case 194: - case 211: - case 171: - case 141: - case 172: - case 142: + case 196: + case 213: + case 173: case 143: + case 174: case 144: - return child !== 190; + case 145: + case 146: + return child !== 192; default: return false; } @@ -35417,7 +35981,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(269, nodes.pos, nodes.end, 4096, this); + var list = createNode(271, nodes.pos, nodes.end, 4096, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -35436,7 +36000,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 133) { + if (this.kind >= 135) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -35483,7 +36047,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 133 ? child : child.getFirstToken(sourceFile); + return child.kind < 135 ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -35491,7 +36055,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 133 ? child : child.getLastToken(sourceFile); + return child.kind < 135 ? child : child.getLastToken(sourceFile); }; return NodeObject; })(); @@ -35533,7 +36097,7 @@ var ts; ts.forEach(declarations, function (declaration, indexOfDeclaration) { if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); - if (canUseParsedParamTagComments && declaration.kind === 136) { + if (canUseParsedParamTagComments && declaration.kind === 138) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -35541,13 +36105,13 @@ var ts; } }); } - if (declaration.kind === 216 && declaration.body.kind === 216) { + if (declaration.kind === 218 && declaration.body.kind === 218) { return; } - while (declaration.kind === 216 && declaration.parent.kind === 216) { + while (declaration.kind === 218 && declaration.parent.kind === 218) { declaration = declaration.parent; } - ts.forEach(getJsDocCommentTextRange(declaration.kind === 209 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 211 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); @@ -35857,9 +36421,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 134) { + if (declaration.name.kind === 136) { var expr = declaration.name.expression; - if (expr.kind === 164) { + if (expr.kind === 166) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -35869,7 +36433,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 67 || + if (node.kind === 69 || node.kind === 9 || node.kind === 8) { return node.text; @@ -35879,9 +36443,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 211: - case 141: - case 140: + case 213: + case 143: + case 142: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -35898,62 +36462,62 @@ var ts; ts.forEachChild(node, visit); } break; - case 212: - case 213: case 214: case 215: case 216: - case 219: - case 228: - case 224: - case 219: + case 217: + case 218: case 221: - case 222: - case 143: - case 144: - case 153: + case 230: + case 226: + case 221: + case 223: + case 224: + case 145: + case 146: + case 155: addDeclaration(node); - case 142: - case 191: - case 210: - case 159: - case 160: - case 217: + case 144: + case 193: + case 212: + case 161: + case 162: + case 219: ts.forEachChild(node, visit); break; - case 190: + case 192: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 136: + case 138: if (!(node.flags & 112)) { break; } - case 209: - case 161: + case 211: + case 163: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 245: - case 139: - case 138: + case 247: + case 141: + case 140: addDeclaration(node); break; - case 226: + case 228: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 220: + case 222: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222) { + if (importClause.namedBindings.kind === 224) { addDeclaration(importClause.namedBindings); } else { @@ -35980,6 +36544,12 @@ var ts; HighlightSpanKind.reference = "reference"; HighlightSpanKind.writtenReference = "writtenReference"; })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); + (function (IndentStyle) { + IndentStyle[IndentStyle["None"] = 0] = "None"; + IndentStyle[IndentStyle["Block"] = 1] = "Block"; + IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; + })(ts.IndentStyle || (ts.IndentStyle = {})); + var IndentStyle = ts.IndentStyle; (function (SymbolDisplayPartKind) { SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; @@ -36095,14 +36665,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 171) { + if (declaration.kind === 173) { return true; } - if (declaration.kind !== 209 && declaration.kind !== 211) { + if (declaration.kind !== 211 && declaration.kind !== 213) { return false; } for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { - if (parent_8.kind === 246 || parent_8.kind === 217) { + if (parent_8.kind === 248 || parent_8.kind === 219) { return false; } } @@ -36213,7 +36783,7 @@ var ts; options.allowNonTsExtensions = true; options.noLib = true; options.noResolve = true; - var inputFileName = transpileOptions.fileName || "module.ts"; + var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); var sourceFile = ts.createSourceFile(inputFileName, input, options.target); if (transpileOptions.moduleName) { sourceFile.moduleName = transpileOptions.moduleName; @@ -36394,8 +36964,9 @@ var ts; }; } ts.createDocumentRegistry = createDocumentRegistry; - function preProcessFile(sourceText, readImportFiles) { + function preProcessFile(sourceText, readImportFiles, detectJavaScriptImports) { if (readImportFiles === void 0) { readImportFiles = true; } + if (detectJavaScriptImports === void 0) { detectJavaScriptImports = false; } var referencedFiles = []; var importedFiles = []; var ambientExternalModules; @@ -36429,98 +37000,58 @@ var ts; end: pos + importPath.length }); } - function processImport() { - scanner.setText(sourceText); - var token = scanner.scan(); - while (token !== 1) { - if (token === 120) { - token = scanner.scan(); - if (token === 123) { - token = scanner.scan(); - if (token === 9) { - recordAmbientExternalModule(); - continue; - } - } - } - else if (token === 87) { + function tryConsumeDeclare() { + var token = scanner.getToken(); + if (token === 122) { + token = scanner.scan(); + if (token === 125) { token = scanner.scan(); if (token === 9) { - recordModuleName(); - continue; + recordAmbientExternalModule(); } - else { - if (token === 67 || ts.isKeyword(token)) { + } + return true; + } + return false; + } + function tryConsumeImport() { + var token = scanner.getToken(); + if (token === 89) { + token = scanner.scan(); + if (token === 9) { + recordModuleName(); + return true; + } + else { + if (token === 69 || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 133) { token = scanner.scan(); - if (token === 131) { - token = scanner.scan(); - if (token === 9) { - recordModuleName(); - continue; - } - } - else if (token === 55) { - token = scanner.scan(); - if (token === 125) { - token = scanner.scan(); - if (token === 17) { - token = scanner.scan(); - if (token === 9) { - recordModuleName(); - continue; - } - } - } - } - else if (token === 24) { - token = scanner.scan(); - } - else { - continue; + if (token === 9) { + recordModuleName(); + return true; } } - if (token === 15) { - token = scanner.scan(); - while (token !== 16) { - token = scanner.scan(); - } - if (token === 16) { - token = scanner.scan(); - if (token === 131) { - token = scanner.scan(); - if (token === 9) { - recordModuleName(); - } - } + else if (token === 56) { + if (tryConsumeRequireCall(true)) { + return true; } } - else if (token === 37) { + else if (token === 24) { token = scanner.scan(); - if (token === 114) { - token = scanner.scan(); - if (token === 67 || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 131) { - token = scanner.scan(); - if (token === 9) { - recordModuleName(); - } - } - } - } + } + else { + return true; } } - } - else if (token === 80) { - token = scanner.scan(); if (token === 15) { token = scanner.scan(); - while (token !== 16) { + while (token !== 16 && token !== 1) { token = scanner.scan(); } if (token === 16) { token = scanner.scan(); - if (token === 131) { + if (token === 133) { token = scanner.scan(); if (token === 9) { recordModuleName(); @@ -36530,38 +37061,135 @@ var ts; } else if (token === 37) { token = scanner.scan(); - if (token === 131) { + if (token === 116) { + token = scanner.scan(); + if (token === 69 || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 133) { + token = scanner.scan(); + if (token === 9) { + recordModuleName(); + } + } + } + } + } + } + return true; + } + return false; + } + function tryConsumeExport() { + var token = scanner.getToken(); + if (token === 82) { + token = scanner.scan(); + if (token === 15) { + token = scanner.scan(); + while (token !== 16 && token !== 1) { + token = scanner.scan(); + } + if (token === 16) { + token = scanner.scan(); + if (token === 133) { token = scanner.scan(); if (token === 9) { recordModuleName(); } } } - else if (token === 87) { + } + else if (token === 37) { + token = scanner.scan(); + if (token === 133) { token = scanner.scan(); - if (token === 67 || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 55) { - token = scanner.scan(); - if (token === 125) { - token = scanner.scan(); - if (token === 17) { - token = scanner.scan(); - if (token === 9) { - recordModuleName(); - } - } - } + if (token === 9) { + recordModuleName(); + } + } + } + else if (token === 89) { + token = scanner.scan(); + if (token === 69 || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 56) { + if (tryConsumeRequireCall(true)) { + return true; } } } } + return true; + } + return false; + } + function tryConsumeRequireCall(skipCurrentToken) { + var token = skipCurrentToken ? scanner.scan() : scanner.getToken(); + if (token === 127) { token = scanner.scan(); + if (token === 17) { + token = scanner.scan(); + if (token === 9) { + recordModuleName(); + } + } + return true; + } + return false; + } + function tryConsumeDefine() { + var token = scanner.getToken(); + if (token === 69 && scanner.getTokenValue() === "define") { + token = scanner.scan(); + if (token !== 17) { + return true; + } + token = scanner.scan(); + if (token === 9) { + token = scanner.scan(); + if (token === 24) { + token = scanner.scan(); + } + else { + return true; + } + } + if (token !== 19) { + return true; + } + token = scanner.scan(); + var i = 0; + while (token !== 20 && token !== 1) { + if (token === 9) { + recordModuleName(); + i++; + } + token = scanner.scan(); + } + return true; + } + return false; + } + function processImports() { + scanner.setText(sourceText); + scanner.scan(); + while (true) { + if (scanner.getToken() === 1) { + break; + } + if (tryConsumeDeclare() || + tryConsumeImport() || + tryConsumeExport() || + (detectJavaScriptImports && (tryConsumeRequireCall(false) || tryConsumeDefine()))) { + continue; + } + else { + scanner.scan(); + } } scanner.setText(undefined); } if (readImportFiles) { - processImport(); + processImports(); } processTripleSlashDirectives(); return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules }; @@ -36569,7 +37197,7 @@ var ts; ts.preProcessFile = preProcessFile; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 205 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 207 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -36577,17 +37205,17 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 67 && - (node.parent.kind === 201 || node.parent.kind === 200) && + return node.kind === 69 && + (node.parent.kind === 203 || node.parent.kind === 202) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 67 && - node.parent.kind === 205 && + return node.kind === 69 && + node.parent.kind === 207 && node.parent.label === node; } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 205; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 207; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -36598,48 +37226,48 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 133 && node.parent.right === node; + return node.parent.kind === 135 && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 164 && node.parent.name === node; + return node && node.parent && node.parent.kind === 166 && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 166 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 168 && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 167 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 169 && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 216 && node.parent.name === node; + return node.parent.kind === 218 && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 67 && + return node.kind === 69 && ts.isFunctionLike(node.parent) && node.parent.name === node; } function isNameOfPropertyAssignment(node) { - return (node.kind === 67 || node.kind === 9 || node.kind === 8) && - (node.parent.kind === 243 || node.parent.kind === 244) && node.parent.name === node; + return (node.kind === 69 || node.kind === 9 || node.kind === 8) && + (node.parent.kind === 245 || node.parent.kind === 246) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 || node.kind === 8) { switch (node.parent.kind) { - case 139: - case 138: - case 243: - case 245: case 141: case 140: + case 245: + case 247: case 143: - case 144: - case 216: + case 142: + case 145: + case 146: + case 218: return node.parent.name === node; - case 165: + case 167: return node.parent.argumentExpression === node; } } @@ -36677,7 +37305,7 @@ var ts; } } var keywordCompletions = []; - for (var i = 68; i <= 132; i++) { + for (var i = 70; i <= 134; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -36692,17 +37320,17 @@ var ts; return undefined; } switch (node.kind) { - case 246: - case 141: - case 140: - case 211: - case 171: + case 248: case 143: - case 144: - case 212: + case 142: case 213: + case 173: + case 145: + case 146: + case 214: case 215: - case 216: + case 217: + case 218: return node; } } @@ -36710,38 +37338,38 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 216: return ScriptElementKind.moduleElement; - case 212: return ScriptElementKind.classElement; - case 213: return ScriptElementKind.interfaceElement; - case 214: return ScriptElementKind.typeElement; - case 215: return ScriptElementKind.enumElement; - case 209: + case 218: return ScriptElementKind.moduleElement; + case 214: return ScriptElementKind.classElement; + case 215: return ScriptElementKind.interfaceElement; + case 216: return ScriptElementKind.typeElement; + case 217: return ScriptElementKind.enumElement; + case 211: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 211: return ScriptElementKind.functionElement; - case 143: return ScriptElementKind.memberGetAccessorElement; - case 144: return ScriptElementKind.memberSetAccessorElement; + case 213: return ScriptElementKind.functionElement; + case 145: return ScriptElementKind.memberGetAccessorElement; + case 146: return ScriptElementKind.memberSetAccessorElement; + case 143: + case 142: + return ScriptElementKind.memberFunctionElement; case 141: case 140: - return ScriptElementKind.memberFunctionElement; - case 139: - case 138: return ScriptElementKind.memberVariableElement; - case 147: return ScriptElementKind.indexSignatureElement; - case 146: return ScriptElementKind.constructSignatureElement; - case 145: return ScriptElementKind.callSignatureElement; - case 142: return ScriptElementKind.constructorImplementationElement; - case 135: return ScriptElementKind.typeParameterElement; - case 245: return ScriptElementKind.variableElement; - case 136: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 219: - case 224: + case 149: return ScriptElementKind.indexSignatureElement; + case 148: return ScriptElementKind.constructSignatureElement; + case 147: return ScriptElementKind.callSignatureElement; + case 144: return ScriptElementKind.constructorImplementationElement; + case 137: return ScriptElementKind.typeParameterElement; + case 247: return ScriptElementKind.variableElement; + case 138: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; case 221: - case 228: - case 222: + case 226: + case 223: + case 230: + case 224: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -36904,7 +37532,7 @@ var ts; function getSemanticDiagnostics(fileName) { synchronizeHostData(); var targetSourceFile = getValidSourceFile(fileName); - if (ts.isJavaScript(fileName)) { + if (ts.isSourceFileJavaScript(targetSourceFile)) { return getJavaScriptSemanticDiagnostics(targetSourceFile); } var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); @@ -36923,44 +37551,44 @@ var ts; return false; } switch (node.kind) { - case 219: + case 221: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 225: + case 227: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 212: + case 214: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 241: + case 243: var heritageClause = node; - if (heritageClause.token === 104) { + if (heritageClause.token === 106) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 213: + case 215: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 216: + case 218: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 214: + case 216: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 141: - case 140: - case 142: case 143: + case 142: case 144: - case 171: - case 211: - case 172: - case 211: + case 145: + case 146: + case 173: + case 213: + case 174: + case 213: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -36968,20 +37596,20 @@ var ts; return true; } break; - case 191: + case 193: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 209: + case 211: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 166: - case 167: + case 168: + case 169: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -36989,7 +37617,7 @@ var ts; return true; } break; - case 136: + case 138: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -37005,17 +37633,17 @@ var ts; return true; } break; - case 139: + case 141: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 215: + case 217: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 169: + case 171: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 137: + case 139: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -37041,17 +37669,17 @@ var ts; for (var _i = 0; _i < modifiers.length; _i++) { var modifier = modifiers[_i]; switch (modifier.kind) { + case 112: case 110: - case 108: - case 109: - case 120: + case 111: + case 122: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; - case 111: - case 80: - case 72: - case 75: case 113: + case 82: + case 74: + case 77: + case 115: } } } @@ -37096,7 +37724,7 @@ var ts; var typeChecker = program.getTypeChecker(); var syntacticStart = new Date().getTime(); var sourceFile = getValidSourceFile(fileName); - var isJavaScriptFile = ts.isJavaScript(fileName); + var isJavaScriptFile = ts.isSourceFileJavaScript(sourceFile); var isJsDocTagName = false; var start = new Date().getTime(); var currentToken = ts.getTokenAtPosition(sourceFile, position); @@ -37115,9 +37743,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { + case 269: case 267: - case 265: - case 266: + case 268: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -37145,6 +37773,7 @@ var ts; var node = currentToken; var isRightOfDot = false; var isRightOfOpenTag = false; + var isStartingCloseTag = false; var location = ts.getTouchingPropertyName(sourceFile, position); if (contextToken) { if (isCompletionListBlocker(contextToken)) { @@ -37153,11 +37782,11 @@ var ts; } var parent_9 = contextToken.parent, kind = contextToken.kind; if (kind === 21) { - if (parent_9.kind === 164) { + if (parent_9.kind === 166) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_9.kind === 133) { + else if (parent_9.kind === 135) { node = contextToken.parent.left; isRightOfDot = true; } @@ -37165,9 +37794,14 @@ var ts; return undefined; } } - else if (kind === 25 && sourceFile.languageVariant === 1) { - isRightOfOpenTag = true; - location = contextToken; + else if (sourceFile.languageVariant === 1) { + if (kind === 25) { + isRightOfOpenTag = true; + location = contextToken; + } + else if (kind === 39 && contextToken.parent.kind === 237) { + isStartingCloseTag = true; + } } } var semanticStart = new Date().getTime(); @@ -37188,6 +37822,12 @@ var ts; isMemberCompletion = true; isNewIdentifierLocation = false; } + else if (isStartingCloseTag) { + var tagName = contextToken.parent.parent.openingElement.tagName; + symbols = [typeChecker.getSymbolAtLocation(tagName)]; + isMemberCompletion = true; + isNewIdentifierLocation = false; + } else { if (!tryGetGlobalSymbols()) { return undefined; @@ -37198,7 +37838,7 @@ var ts; function getTypeScriptMemberSymbols() { isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 67 || node.kind === 133 || node.kind === 164) { + if (node.kind === 69 || node.kind === 135 || node.kind === 166) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -37244,7 +37884,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; - if ((jsxContainer.kind === 232) || (jsxContainer.kind === 233)) { + if ((jsxContainer.kind === 234) || (jsxContainer.kind === 235)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); @@ -37278,49 +37918,64 @@ var ts; var start = new Date().getTime(); var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || isSolelyIdentifierDefinitionLocation(contextToken) || - isDotOfNumericLiteral(contextToken); + isDotOfNumericLiteral(contextToken) || + isInJsxText(contextToken); log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); return result; } + function isInJsxText(contextToken) { + if (contextToken.kind === 236) { + return true; + } + if (contextToken.kind === 27 && contextToken.parent) { + if (contextToken.parent.kind === 235) { + return true; + } + if (contextToken.parent.kind === 237 || contextToken.parent.kind === 234) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 233; + } + } + return false; + } function isNewIdentifierDefinitionLocation(previousToken) { if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 24: - return containingNodeKind === 166 - || containingNodeKind === 142 - || containingNodeKind === 167 - || containingNodeKind === 162 - || containingNodeKind === 179 - || containingNodeKind === 150; + return containingNodeKind === 168 + || containingNodeKind === 144 + || containingNodeKind === 169 + || containingNodeKind === 164 + || containingNodeKind === 181 + || containingNodeKind === 152; case 17: - return containingNodeKind === 166 - || containingNodeKind === 142 - || containingNodeKind === 167 - || containingNodeKind === 170 - || containingNodeKind === 158; + return containingNodeKind === 168 + || containingNodeKind === 144 + || containingNodeKind === 169 + || containingNodeKind === 172 + || containingNodeKind === 160; case 19: - return containingNodeKind === 162 - || containingNodeKind === 147 - || containingNodeKind === 134; - case 123: - case 124: + return containingNodeKind === 164 + || containingNodeKind === 149 + || containingNodeKind === 136; + case 125: + case 126: return true; case 21: - return containingNodeKind === 216; + return containingNodeKind === 218; case 15: - return containingNodeKind === 212; - case 55: - return containingNodeKind === 209 - || containingNodeKind === 179; + return containingNodeKind === 214; + case 56: + return containingNodeKind === 211 + || containingNodeKind === 181; case 12: - return containingNodeKind === 181; + return containingNodeKind === 183; case 13: - return containingNodeKind === 188; + return containingNodeKind === 190; + case 112: case 110: - case 108: - case 109: - return containingNodeKind === 139; + case 111: + return containingNodeKind === 141; } switch (previousToken.getText()) { case "public": @@ -37351,12 +38006,12 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 163) { + if (objectLikeContainer.kind === 165) { isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 159) { + else if (objectLikeContainer.kind === 161) { isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); if (ts.isVariableLike(rootDeclaration)) { @@ -37382,9 +38037,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 223 ? - 220 : - 226; + var declarationKind = namedImportsOrExports.kind === 225 ? + 222 : + 228; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -37406,7 +38061,7 @@ var ts; case 15: case 24: var parent_10 = contextToken.parent; - if (parent_10 && (parent_10.kind === 163 || parent_10.kind === 159)) { + if (parent_10 && (parent_10.kind === 165 || parent_10.kind === 161)) { return parent_10; } break; @@ -37420,8 +38075,8 @@ var ts; case 15: case 24: switch (contextToken.parent.kind) { - case 223: - case 227: + case 225: + case 229: return contextToken.parent; } } @@ -37433,27 +38088,30 @@ var ts; var parent_11 = contextToken.parent; switch (contextToken.kind) { case 26: - case 38: - case 67: - case 236: - case 237: - if (parent_11 && (parent_11.kind === 232 || parent_11.kind === 233)) { + case 39: + case 69: + case 238: + case 239: + if (parent_11 && (parent_11.kind === 234 || parent_11.kind === 235)) { return parent_11; } + else if (parent_11.kind === 238) { + return parent_11.parent; + } break; case 9: - if (parent_11 && ((parent_11.kind === 236) || (parent_11.kind === 237))) { + if (parent_11 && ((parent_11.kind === 238) || (parent_11.kind === 239))) { return parent_11.parent; } break; case 16: if (parent_11 && - parent_11.kind === 238 && + parent_11.kind === 240 && parent_11.parent && - (parent_11.parent.kind === 236)) { + (parent_11.parent.kind === 238)) { return parent_11.parent.parent; } - if (parent_11 && parent_11.kind === 237) { + if (parent_11 && parent_11.kind === 239) { return parent_11.parent; } break; @@ -37463,16 +38121,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 171: - case 172: - case 211: - case 141: - case 140: + case 173: + case 174: + case 213: case 143: - case 144: + case 142: case 145: case 146: case 147: + case 148: + case 149: return true; } return false; @@ -37481,77 +38139,83 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 24: - return containingNodeKind === 209 || - containingNodeKind === 210 || - containingNodeKind === 191 || - containingNodeKind === 215 || - isFunction(containingNodeKind) || + return containingNodeKind === 211 || containingNodeKind === 212 || - containingNodeKind === 184 || - containingNodeKind === 213 || - containingNodeKind === 160 || - containingNodeKind === 214; + containingNodeKind === 193 || + containingNodeKind === 217 || + isFunction(containingNodeKind) || + containingNodeKind === 214 || + containingNodeKind === 186 || + containingNodeKind === 215 || + containingNodeKind === 162 || + containingNodeKind === 216; case 21: - return containingNodeKind === 160; - case 53: - return containingNodeKind === 161; + return containingNodeKind === 162; + case 54: + return containingNodeKind === 163; case 19: - return containingNodeKind === 160; + return containingNodeKind === 162; case 17: - return containingNodeKind === 242 || + return containingNodeKind === 244 || isFunction(containingNodeKind); case 15: - return containingNodeKind === 215 || - containingNodeKind === 213 || - containingNodeKind === 153; + return containingNodeKind === 217 || + containingNodeKind === 215 || + containingNodeKind === 155; case 23: - return containingNodeKind === 138 && + return containingNodeKind === 140 && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 213 || - contextToken.parent.parent.kind === 153); + (contextToken.parent.parent.kind === 215 || + contextToken.parent.parent.kind === 155); case 25: - return containingNodeKind === 212 || - containingNodeKind === 184 || - containingNodeKind === 213 || - containingNodeKind === 214 || + return containingNodeKind === 214 || + containingNodeKind === 186 || + containingNodeKind === 215 || + containingNodeKind === 216 || isFunction(containingNodeKind); - case 111: - return containingNodeKind === 139; + case 113: + return containingNodeKind === 141; case 22: - return containingNodeKind === 136 || + return containingNodeKind === 138 || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 160); + contextToken.parent.parent.kind === 162); + case 112: case 110: + case 111: + return containingNodeKind === 138; + case 116: + return containingNodeKind === 226 || + containingNodeKind === 230 || + containingNodeKind === 224; + case 73: + case 81: + case 107: + case 87: + case 102: + case 123: + case 129: + case 89: case 108: - case 109: - return containingNodeKind === 136; + case 74: case 114: - containingNodeKind === 224 || - containingNodeKind === 228 || - containingNodeKind === 222; - case 71: - case 79: - case 105: - case 85: - case 100: - case 121: - case 127: - case 87: - case 106: - case 72: - case 112: - case 130: + case 132: return true; } switch (contextToken.getText()) { + case "abstract": + case "async": case "class": - case "interface": + case "const": + case "declare": case "enum": case "function": - case "var": - case "static": + case "interface": case "let": - case "const": + case "private": + case "protected": + case "public": + case "static": + case "var": case "yield": return true; } @@ -37571,8 +38235,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_31 = element.propertyName || element.name; - exisingImportsOrExports[name_31.text] = true; + var name_32 = element.propertyName || element.name; + exisingImportsOrExports[name_32.text] = true; } if (ts.isEmpty(exisingImportsOrExports)) { return exportsOfModule; @@ -37586,16 +38250,16 @@ var ts; var existingMemberNames = {}; for (var _i = 0; _i < existingMembers.length; _i++) { var m = existingMembers[_i]; - if (m.kind !== 243 && - m.kind !== 244 && - m.kind !== 161) { + if (m.kind !== 245 && + m.kind !== 246 && + m.kind !== 163) { continue; } if (m.getStart() <= position && position <= m.getEnd()) { continue; } var existingName = void 0; - if (m.kind === 161 && m.propertyName) { + if (m.kind === 163 && m.propertyName) { existingName = m.propertyName.text; } else { @@ -37612,7 +38276,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 236) { + if (attr.kind === 238) { seenNames[attr.name.text] = true; } } @@ -37626,44 +38290,41 @@ var ts; return undefined; } var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; - var entries; if (isJsDocTagName) { return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; } - if (isRightOfDot && ts.isJavaScript(fileName)) { - entries = getCompletionEntriesFromSymbols(symbols); - ts.addRange(entries, getJavaScriptCompletionEntries()); + var sourceFile = getValidSourceFile(fileName); + var entries = []; + if (isRightOfDot && ts.isSourceFileJavaScript(sourceFile)) { + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries); + ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, uniqueNames)); } else { if (!symbols || symbols.length === 0) { return undefined; } - entries = getCompletionEntriesFromSymbols(symbols); + getCompletionEntriesFromSymbols(symbols, entries); } if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - function getJavaScriptCompletionEntries() { + function getJavaScriptCompletionEntries(sourceFile, uniqueNames) { var entries = []; - var allNames = {}; var target = program.getCompilerOptions().target; - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - var nameTable = getNameTable(sourceFile); - for (var name_32 in nameTable) { - if (!allNames[name_32]) { - allNames[name_32] = name_32; - var displayName = getCompletionEntryDisplayName(name_32, target, true); - if (displayName) { - var entry = { - name: displayName, - kind: ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; - entries.push(entry); - } + var nameTable = getNameTable(sourceFile); + for (var name_33 in nameTable) { + if (!uniqueNames[name_33]) { + uniqueNames[name_33] = name_33; + var displayName = getCompletionEntryDisplayName(name_33, target, true); + if (displayName) { + var entry = { + name: displayName, + kind: ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); } } } @@ -37691,25 +38352,24 @@ var ts; sortText: "0" }; } - function getCompletionEntriesFromSymbols(symbols) { + function getCompletionEntriesFromSymbols(symbols, entries) { var start = new Date().getTime(); - var entries = []; + var uniqueNames = {}; if (symbols) { - var nameToSymbol = {}; for (var _i = 0; _i < symbols.length; _i++) { var symbol = symbols[_i]; var entry = createCompletionEntry(symbol, location); if (entry) { var id = ts.escapeIdentifier(entry.name); - if (!ts.lookUp(nameToSymbol, id)) { + if (!ts.lookUp(uniqueNames, id)) { entries.push(entry); - nameToSymbol[id] = symbol; + uniqueNames[id] = id; } } } } log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start)); - return entries; + return uniqueNames; } } function getCompletionEntryDetails(fileName, position, entryName) { @@ -37745,7 +38405,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32) - return ts.getDeclarationOfKind(symbol, 184) ? + return ts.getDeclarationOfKind(symbol, 186) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384) return ScriptElementKind.enumElement; @@ -37841,14 +38501,14 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 164) { + if (location.parent && location.parent.kind === 166) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpression; - if (location.kind === 166 || location.kind === 167) { + if (location.kind === 168 || location.kind === 169) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -37860,9 +38520,9 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 167 || callExpression.expression.kind === 93; + var useConstructSignatures = callExpression.kind === 169 || callExpression.expression.kind === 95; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); - if (!ts.contains(allSignatures, signature.target || signature)) { + if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; } if (signature) { @@ -37875,7 +38535,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(90)); + displayParts.push(ts.keywordPart(92)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -37890,10 +38550,10 @@ var ts; case ScriptElementKind.letElement: case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: - displayParts.push(ts.punctuationPart(53)); + displayParts.push(ts.punctuationPart(54)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(90)); + displayParts.push(ts.keywordPart(92)); displayParts.push(ts.spacePart()); } if (!(type.flags & 65536)) { @@ -37908,21 +38568,21 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 119 && location.parent.kind === 142)) { + (location.kind === 121 && location.parent.kind === 144)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 142 ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 144 ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 142) { + if (functionDeclaration.kind === 144) { symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 145 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 147 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -37931,11 +38591,11 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 184)) { + if (ts.getDeclarationOfKind(symbol, 186)) { pushTypePart(ScriptElementKind.localClassElement); } else { - displayParts.push(ts.keywordPart(71)); + displayParts.push(ts.keywordPart(73)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -37943,37 +38603,37 @@ var ts; } if ((symbolFlags & 64) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(105)); + displayParts.push(ts.keywordPart(107)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(130)); + displayParts.push(ts.keywordPart(132)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55)); + displayParts.push(ts.operatorPart(56)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(72)); + displayParts.push(ts.keywordPart(74)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(79)); + displayParts.push(ts.keywordPart(81)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 216); - var isNamespace = declaration && declaration.name && declaration.name.kind === 67; - displayParts.push(ts.keywordPart(isNamespace ? 124 : 123)); + var declaration = ts.getDeclarationOfKind(symbol, 218); + var isNamespace = declaration && declaration.name && declaration.name.kind === 69; + displayParts.push(ts.keywordPart(isNamespace ? 126 : 125)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -37985,7 +38645,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(88)); + displayParts.push(ts.keywordPart(90)); displayParts.push(ts.spacePart()); if (symbol.parent) { addFullSymbolName(symbol.parent, enclosingDeclaration); @@ -37994,20 +38654,20 @@ var ts; else { var container = ts.getContainingFunction(location); if (container) { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 137).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 146) { - displayParts.push(ts.keywordPart(90)); + if (signatureDeclaration.kind === 148) { + displayParts.push(ts.keywordPart(92)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 145 && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 147 && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } else { - var declaration = ts.getDeclarationOfKind(symbol, 135).parent; - displayParts.push(ts.keywordPart(130)); + var declaration = ts.getDeclarationOfKind(symbol, 137).parent; + displayParts.push(ts.keywordPart(132)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -38017,11 +38677,11 @@ var ts; if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 245) { + if (declaration.kind === 247) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55)); + displayParts.push(ts.operatorPart(56)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } @@ -38029,17 +38689,17 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(87)); + displayParts.push(ts.keywordPart(89)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 219) { + if (declaration.kind === 221) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55)); + displayParts.push(ts.operatorPart(56)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(125)); + displayParts.push(ts.keywordPart(127)); displayParts.push(ts.punctuationPart(17)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(18)); @@ -38048,7 +38708,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55)); + displayParts.push(ts.operatorPart(56)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -38064,7 +38724,7 @@ var ts; if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(53)); + displayParts.push(ts.punctuationPart(54)); displayParts.push(ts.spacePart()); if (type.symbol && type.symbol.flags & 262144) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { @@ -38162,11 +38822,11 @@ var ts; var symbol = typeChecker.getSymbolAtLocation(node); if (!symbol) { switch (node.kind) { - case 67: - case 164: - case 133: + case 69: + case 166: + case 135: + case 97: case 95: - case 93: var type = typeChecker.getTypeAtLocation(node); if (type) { return { @@ -38215,7 +38875,7 @@ var ts; } return result; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (isNewExpressionTarget(location) || location.kind === 119) { + if (isNewExpressionTarget(location) || location.kind === 121) { if (symbol.flags & 32) { for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { var declaration = _a[_i]; @@ -38238,8 +38898,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 142) || - (!selectConstructors && (d.kind === 211 || d.kind === 141 || d.kind === 140))) { + if ((selectConstructors && d.kind === 144) || + (!selectConstructors && (d.kind === 213 || d.kind === 143 || d.kind === 142))) { declarations.push(d); if (d.body) definition = d; @@ -38290,11 +38950,11 @@ var ts; } if (symbol.flags & 8388608) { var declaration = symbol.declarations[0]; - if (node.kind === 67 && node.parent === declaration) { + if (node.kind === 69 && node.parent === declaration) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 244) { + if (node.parent.kind === 246) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -38365,9 +39025,9 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 67 || + if (node.kind === 69 || + node.kind === 97 || node.kind === 95 || - node.kind === 93 || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, false, false); @@ -38416,77 +39076,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 86: - case 78: - if (hasKind(node.parent, 194)) { + case 88: + case 80: + if (hasKind(node.parent, 196)) { return getIfElseOccurrences(node.parent); } break; - case 92: - if (hasKind(node.parent, 202)) { + case 94: + if (hasKind(node.parent, 204)) { return getReturnOccurrences(node.parent); } break; - case 96: - if (hasKind(node.parent, 206)) { + case 98: + if (hasKind(node.parent, 208)) { return getThrowOccurrences(node.parent); } break; - case 70: - if (hasKind(parent(parent(node)), 207)) { + case 72: + if (hasKind(parent(parent(node)), 209)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 98: - case 83: - if (hasKind(parent(node), 207)) { + case 100: + case 85: + if (hasKind(parent(node), 209)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 94: - if (hasKind(node.parent, 204)) { + case 96: + if (hasKind(node.parent, 206)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 69: - case 75: - if (hasKind(parent(parent(parent(node))), 204)) { + case 71: + case 77: + if (hasKind(parent(parent(parent(node))), 206)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 68: - case 73: - if (hasKind(node.parent, 201) || hasKind(node.parent, 200)) { + case 70: + case 75: + if (hasKind(node.parent, 203) || hasKind(node.parent, 202)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 84: - if (hasKind(node.parent, 197) || - hasKind(node.parent, 198) || - hasKind(node.parent, 199)) { + case 86: + if (hasKind(node.parent, 199) || + hasKind(node.parent, 200) || + hasKind(node.parent, 201)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 102: - case 77: - if (hasKind(node.parent, 196) || hasKind(node.parent, 195)) { + case 104: + case 79: + if (hasKind(node.parent, 198) || hasKind(node.parent, 197)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 119: - if (hasKind(node.parent, 142)) { + case 121: + if (hasKind(node.parent, 144)) { return getConstructorOccurrences(node.parent); } break; - case 121: - case 127: - if (hasKind(node.parent, 143) || hasKind(node.parent, 144)) { + case 123: + case 129: + if (hasKind(node.parent, 145) || hasKind(node.parent, 146)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 191)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 193)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -38498,10 +39158,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 206) { + if (node.kind === 208) { statementAccumulator.push(node); } - else if (node.kind === 207) { + else if (node.kind === 209) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -38523,10 +39183,10 @@ var ts; var child = throwStatement; while (child.parent) { var parent_12 = child.parent; - if (ts.isFunctionBlock(parent_12) || parent_12.kind === 246) { + if (ts.isFunctionBlock(parent_12) || parent_12.kind === 248) { return parent_12; } - if (parent_12.kind === 207) { + if (parent_12.kind === 209) { var tryStatement = parent_12; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; @@ -38541,7 +39201,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 201 || node.kind === 200) { + if (node.kind === 203 || node.kind === 202) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -38557,15 +39217,15 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 204: - if (statement.kind === 200) { + case 206: + if (statement.kind === 202) { continue; } - case 197: - case 198: case 199: - case 196: - case 195: + case 200: + case 201: + case 198: + case 197: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -38582,24 +39242,24 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 212 || - container.kind === 184 || - (declaration.kind === 136 && hasKind(container, 142)))) { + if (!(container.kind === 214 || + container.kind === 186 || + (declaration.kind === 138 && hasKind(container, 144)))) { return undefined; } } - else if (modifier === 111) { - if (!(container.kind === 212 || container.kind === 184)) { + else if (modifier === 113) { + if (!(container.kind === 214 || container.kind === 186)) { return undefined; } } - else if (modifier === 80 || modifier === 120) { - if (!(container.kind === 217 || container.kind === 246)) { + else if (modifier === 82 || modifier === 122) { + if (!(container.kind === 219 || container.kind === 248)) { return undefined; } } - else if (modifier === 113) { - if (!(container.kind === 212 || declaration.kind === 212)) { + else if (modifier === 115) { + if (!(container.kind === 214 || declaration.kind === 214)) { return undefined; } } @@ -38610,8 +39270,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 217: - case 246: + case 219: + case 248: if (modifierFlag & 256) { nodes = declaration.members.concat(declaration); } @@ -38619,15 +39279,15 @@ var ts; nodes = container.statements; } break; - case 142: + case 144: nodes = container.parameters.concat(container.parent.members); break; - case 212: - case 184: + case 214: + case 186: nodes = container.members; if (modifierFlag & 112) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 142 && member; + return member.kind === 144 && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -38648,19 +39308,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 110: + case 112: return 16; - case 108: + case 110: return 32; - case 109: - return 64; case 111: + return 64; + case 113: return 128; - case 80: + case 82: return 1; - case 120: + case 122: return 2; - case 113: + case 115: return 256; default: ts.Debug.fail(); @@ -38680,13 +39340,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 143); - tryPushAccessorKeyword(accessorDeclaration.symbol, 144); + tryPushAccessorKeyword(accessorDeclaration.symbol, 145); + tryPushAccessorKeyword(accessorDeclaration.symbol, 146); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 121, 127); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 123, 129); }); } } } @@ -38695,18 +39355,18 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 119); + return pushKeywordIf(keywords, token, 121); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 84, 102, 77)) { - if (loopNode.kind === 195) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86, 104, 79)) { + if (loopNode.kind === 197) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 102)) { + if (pushKeywordIf(keywords, loopTokens[i], 104)) { break; } } @@ -38715,7 +39375,7 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 68, 73); + pushKeywordIf(keywords, statement.getFirstToken(), 70, 75); } }); return ts.map(keywords, getHighlightSpanForNode); @@ -38724,13 +39384,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { + case 199: + case 200: + case 201: case 197: case 198: - case 199: - case 195: - case 196: return getLoopBreakContinueOccurrences(owner); - case 204: + case 206: return getSwitchCaseDefaultOccurrences(owner); } } @@ -38738,13 +39398,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 94); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 96); ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 69, 75); + pushKeywordIf(keywords, clause.getFirstToken(), 71, 77); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 68); + pushKeywordIf(keywords, statement.getFirstToken(), 70); } }); }); @@ -38752,13 +39412,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 98); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 100); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 70); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 83, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 83); + var finallyKeyword = ts.findChildOfKind(tryStatement, 85, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 85); } return ts.map(keywords, getHighlightSpanForNode); } @@ -38769,50 +39429,50 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 96); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 98); }); if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 92); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 94); }); } return ts.map(keywords, getHighlightSpanForNode); } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 190))) { + if (!(func && hasKind(func.body, 192))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 92); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 94); }); ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 96); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 98); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 194) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 196) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 86); + pushKeywordIf(keywords, children[0], 88); for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 78)) { + if (pushKeywordIf(keywords, children[i], 80)) { break; } } - if (!hasKind(ifStatement.elseStatement, 194)) { + if (!hasKind(ifStatement.elseStatement, 196)) { break; } ifStatement = ifStatement.elseStatement; } var result = []; for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 78 && i < keywords.length - 1) { + if (keywords[i].kind === 80 && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; var shouldCombindElseAndIf = true; @@ -38890,12 +39550,12 @@ var ts; if (!node) { return undefined; } - if (node.kind !== 67 && + if (node.kind !== 69 && !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 67 || node.kind === 8 || node.kind === 9); + ts.Debug.assert(node.kind === 69 || node.kind === 8 || node.kind === 9); return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { @@ -38909,10 +39569,10 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 95) { + if (node.kind === 97) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 93) { + if (node.kind === 95) { return getReferencesForSuperKeyword(node); } var symbol = typeChecker.getSymbolAtLocation(node); @@ -38963,7 +39623,7 @@ var ts; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 224 || declaration.kind === 228; + return declaration.kind === 226 || declaration.kind === 230; }); } function getInternedName(symbol, location, declarations) { @@ -38976,13 +39636,13 @@ var ts; } function getSymbolScope(symbol) { var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 171 || valueDeclaration.kind === 184)) { + if (valueDeclaration && (valueDeclaration.kind === 173 || valueDeclaration.kind === 186)) { return valueDeclaration; } 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, 212); + return ts.getAncestor(privateDeclaration, 214); } } if (symbol.flags & 8388608) { @@ -39003,7 +39663,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 246 && !ts.isExternalModule(container)) { + if (container.kind === 248 && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -39062,7 +39722,7 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { if (node) { switch (node.kind) { - case 67: + case 69: return node.getWidth() === searchSymbolName.length; case 9: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || @@ -39150,13 +39810,13 @@ var ts; } var staticFlag = 128; switch (searchSpaceNode.kind) { - case 139: - case 138: case 141: case 140: - case 142: case 143: + case 142: case 144: + case 145: + case 146: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; @@ -39169,7 +39829,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 93) { + if (!node || node.kind !== 95) { return; } var container = ts.getSuperContainer(node, false); @@ -39184,32 +39844,32 @@ var ts; var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 128; switch (searchSpaceNode.kind) { - case 141: - case 140: + case 143: + case 142: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } - case 139: - case 138: - case 142: - case 143: + case 141: + case 140: case 144: + case 145: + case 146: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; - case 246: + case 248: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 211: - case 171: + case 213: + case 173: break; default: return undefined; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 246) { + if (searchSpaceNode.kind === 248) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -39235,31 +39895,31 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 95) { + if (!node || node.kind !== 97) { return; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 171: - case 211: + case 173: + case 213: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 141: - case 140: + case 143: + case 142: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 184: - case 212: + case 186: + case 214: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 246: - if (container.kind === 246 && !ts.isExternalModule(container)) { + case 248: + if (container.kind === 248 && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -39294,11 +39954,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 | 64)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 212) { + if (declaration.kind === 214) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 213) { + else if (declaration.kind === 215) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -39348,17 +40008,17 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_33 = node.text; + var name_34 = node.text; if (contextualType) { if (contextualType.flags & 16384) { - var unionProperty = contextualType.getProperty(name_33); + var unionProperty = contextualType.getProperty(name_34); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_33); + var symbol = t.getProperty(name_34); if (symbol) { result_4.push(symbol); } @@ -39367,7 +40027,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_33); + var symbol_1 = contextualType.getProperty(name_34); if (symbol_1) { return [symbol_1]; } @@ -39407,17 +40067,17 @@ var ts; }; } function isWriteAccess(node) { - if (node.kind === 67 && ts.isDeclarationName(node)) { + if (node.kind === 69 && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 178 || parent.kind === 177) { + if (parent.kind === 180 || parent.kind === 179) { return true; } - else if (parent.kind === 179 && parent.left === node) { + else if (parent.kind === 181 && parent.left === node) { var operator = parent.operatorToken.kind; - return 55 <= operator && operator <= 66; + return 56 <= operator && operator <= 68; } } return false; @@ -39448,33 +40108,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 136: - case 209: - case 161: - case 139: case 138: - case 243: - case 244: - case 245: + case 211: + case 163: case 141: case 140: - case 142: + case 245: + case 246: + case 247: case 143: + case 142: case 144: - case 211: - case 171: - case 172: - case 242: - return 1; - case 135: + case 145: + case 146: case 213: - case 214: - case 153: - return 2; - case 212: + case 173: + case 174: + case 244: + return 1; + case 137: case 215: - return 1 | 2; case 216: + case 155: + return 2; + case 214: + case 217: + return 1 | 2; + case 218: if (node.name.kind === 9) { return 4 | 1; } @@ -39484,14 +40144,14 @@ var ts; else { return 4; } - case 223: - case 224: - case 219: - case 220: case 225: case 226: + case 221: + case 222: + case 227: + case 228: return 1 | 2 | 4; - case 246: + case 248: return 4 | 1; } return 1 | 2 | 4; @@ -39501,8 +40161,9 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 149 || - (node.parent.kind === 186 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); + return node.parent.kind === 151 || + (node.parent.kind === 188 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + node.kind === 97 && !ts.isExpression(node); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -39510,47 +40171,47 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 164) { - while (root.parent && root.parent.kind === 164) { + if (root.parent.kind === 166) { + while (root.parent && root.parent.kind === 166) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 186 && root.parent.parent.kind === 241) { + if (!isLastClause && root.parent.kind === 188 && root.parent.parent.kind === 243) { var decl = root.parent.parent.parent; - return (decl.kind === 212 && root.parent.parent.token === 104) || - (decl.kind === 213 && root.parent.parent.token === 81); + return (decl.kind === 214 && root.parent.parent.token === 106) || + (decl.kind === 215 && root.parent.parent.token === 83); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 133) { - while (root.parent && root.parent.kind === 133) { + if (root.parent.kind === 135) { + while (root.parent && root.parent.kind === 135) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 149 && !isLastClause; + return root.parent.kind === 151 && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 133) { + while (node.parent.kind === 135) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 67); - if (node.parent.kind === 133 && + ts.Debug.assert(node.kind === 69); + if (node.parent.kind === 135 && node.parent.right === node && - node.parent.parent.kind === 219) { + node.parent.parent.kind === 221) { return 1 | 2 | 4; } return 4; } function getMeaningFromLocation(node) { - if (node.parent.kind === 225) { + if (node.parent.kind === 227) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -39584,15 +40245,15 @@ var ts; return; } switch (node.kind) { - case 164: - case 133: + case 166: + case 135: case 9: - case 82: - case 97: - case 91: + case 84: + case 99: case 93: case 95: - case 67: + case 97: + case 69: break; default: return; @@ -39603,7 +40264,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 216 && + if (nodeForStartPos.parent.parent.kind === 218 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -39630,10 +40291,10 @@ var ts; } function checkForClassificationCancellation(kind) { switch (kind) { - case 216: - case 212: + case 218: + case 214: + case 215: case 213: - case 211: cancellationToken.throwIfCancellationRequested(); } } @@ -39681,7 +40342,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 216 && + return declaration.kind === 218 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -39690,7 +40351,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(kind); - if (kind === 67 && !ts.nodeIsMissing(node)) { + if (kind === 69 && !ts.nodeIsMissing(node)) { var identifier = node; if (classifiableNames[identifier.text]) { var symbol = typeChecker.getSymbolAtLocation(node); @@ -39814,16 +40475,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 265: + case 267: processJSDocParameterTag(tag); break; - case 268: + case 270: processJSDocTemplateTag(tag); break; - case 267: + case 269: processElement(tag.typeExpression); break; - case 266: + case 268: processElement(tag.typeExpression); break; } @@ -39903,17 +40564,17 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 55) { - if (token.parent.kind === 209 || - token.parent.kind === 139 || - token.parent.kind === 136) { + if (tokenKind === 56) { + if (token.parent.kind === 211 || + token.parent.kind === 141 || + token.parent.kind === 138) { return 5; } } - if (token.parent.kind === 179 || - token.parent.kind === 177 || - token.parent.kind === 178 || - token.parent.kind === 180) { + if (token.parent.kind === 181 || + token.parent.kind === 179 || + token.parent.kind === 180 || + token.parent.kind === 182) { return 5; } } @@ -39931,35 +40592,35 @@ var ts; else if (ts.isTemplateLiteralKind(tokenKind)) { return 6; } - else if (tokenKind === 67) { + else if (tokenKind === 69) { if (token) { switch (token.parent.kind) { - case 212: + case 214: if (token.parent.name === token) { return 11; } return; - case 135: + case 137: if (token.parent.name === token) { return 15; } return; - case 213: + case 215: if (token.parent.name === token) { return 13; } return; - case 215: + case 217: if (token.parent.name === token) { return 12; } return; - case 216: + case 218: if (token.parent.name === token) { return 14; } return; - case 136: + case 138: if (token.parent.name === token) { return 17; } @@ -40073,19 +40734,40 @@ var ts; if (!tokenAtPos || tokenStart < position) { return undefined; } - var containingFunction = ts.getAncestor(tokenAtPos, 211); - if (!containingFunction || containingFunction.getStart() < position) { + var commentOwner; + findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { + switch (commentOwner.kind) { + case 213: + case 143: + case 144: + case 214: + case 193: + break findOwner; + case 248: + return undefined; + case 218: + if (commentOwner.parent.kind === 218) { + return undefined; + } + break findOwner; + } + } + if (!commentOwner || commentOwner.getStart() < position) { return undefined; } - var parameters = containingFunction.parameters; + var parameters = getParametersForJsDocOwningNode(commentOwner); var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; - var docParams = parameters.reduce(function (prev, cur, index) { - return prev + - indentationStr + " * @param " + (cur.name.kind === 67 ? cur.name.text : "param" + index) + newLine; - }, ""); + var docParams = ""; + for (var i = 0, numParams = parameters.length; i < numParams; i++) { + var currentName = parameters[i].name; + var paramName = currentName.kind === 69 ? + currentName.text : + "param" + i; + docParams += indentationStr + " * @param " + paramName + newLine; + } var preamble = "/**" + newLine + indentationStr + " * "; var result = preamble + newLine + @@ -40094,6 +40776,38 @@ var ts; (tokenStart === position ? newLine + indentationStr : ""); return { newText: result, caretOffset: preamble.length }; } + function getParametersForJsDocOwningNode(commentOwner) { + if (ts.isFunctionLike(commentOwner)) { + return commentOwner.parameters; + } + if (commentOwner.kind === 193) { + var varStatement = commentOwner; + var varDeclarations = varStatement.declarationList.declarations; + if (varDeclarations.length === 1 && varDeclarations[0].initializer) { + return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); + } + } + return emptyArray; + } + function getParametersFromRightHandSideOfAssignment(rightHandSide) { + while (rightHandSide.kind === 172) { + rightHandSide = rightHandSide.expression; + } + switch (rightHandSide.kind) { + case 173: + case 174: + return rightHandSide.parameters; + case 186: + for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.kind === 144) { + return member.parameters; + } + } + break; + } + return emptyArray; + } function getTodoComments(fileName, descriptors) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); @@ -40158,7 +40872,7 @@ var ts; var sourceFile = getValidSourceFile(fileName); var typeChecker = program.getTypeChecker(); var node = ts.getTouchingWord(sourceFile, position); - if (node && node.kind === 67) { + if (node && node.kind === 69) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { var declarations = symbol.getDeclarations(); @@ -40256,13 +40970,13 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 67: + case 69: nameTable[node.text] = node.text; break; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 230 || + node.parent.kind === 232 || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -40275,31 +40989,31 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 165 && + node.parent.kind === 167 && node.parent.argumentExpression === node; } function createClassifier() { var scanner = ts.createScanner(2, false); var noRegexTable = []; - noRegexTable[67] = true; + noRegexTable[69] = true; noRegexTable[9] = true; noRegexTable[8] = true; noRegexTable[10] = true; - noRegexTable[95] = true; - noRegexTable[40] = true; + noRegexTable[97] = true; noRegexTable[41] = true; + noRegexTable[42] = true; noRegexTable[18] = true; noRegexTable[20] = true; noRegexTable[16] = true; - noRegexTable[97] = true; - noRegexTable[82] = true; + noRegexTable[99] = true; + noRegexTable[84] = true; var templateStack = []; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 121 || - keyword2 === 127 || - keyword2 === 119 || - keyword2 === 111) { + if (keyword2 === 123 || + keyword2 === 129 || + keyword2 === 121 || + keyword2 === 113) { return true; } return false; @@ -40394,31 +41108,31 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 38 || token === 59) && !noRegexTable[lastNonTriviaToken]) { + if ((token === 39 || token === 61) && !noRegexTable[lastNonTriviaToken]) { if (scanner.reScanSlashToken() === 10) { token = 10; } } else if (lastNonTriviaToken === 21 && isKeyword(token)) { - token = 67; + token = 69; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - token = 67; + token = 69; } - else if (lastNonTriviaToken === 67 && + else if (lastNonTriviaToken === 69 && token === 25) { angleBracketStack++; } else if (token === 27 && angleBracketStack > 0) { angleBracketStack--; } - else if (token === 115 || + else if (token === 117 || + token === 130 || token === 128 || - token === 126 || - token === 118 || - token === 129) { + token === 120 || + token === 131) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - token = 67; + token = 69; } } else if (token === 12) { @@ -40516,40 +41230,41 @@ var ts; function isBinaryExpressionOperatorToken(token) { switch (token) { case 37: - case 38: case 39: + case 40: case 35: case 36: - case 42: case 43: case 44: + case 45: case 25: case 27: case 28: case 29: - case 89: - case 88: + case 91: + case 90: + case 116: case 30: case 31: case 32: case 33: - case 45: - case 47: case 46: - case 50: + case 48: + case 47: case 51: - case 65: - case 64: + case 52: + case 67: case 66: - case 61: - case 62: + case 68: case 63: - case 56: + case 64: + case 65: case 57: case 58: case 59: - case 60: - case 55: + case 61: + case 62: + case 56: case 24: return true; default: @@ -40560,17 +41275,17 @@ var ts; switch (token) { case 35: case 36: + case 50: case 49: - case 48: - case 40: case 41: + case 42: return true; default: return false; } } function isKeyword(token) { - return token >= 68 && token <= 132; + return token >= 70 && token <= 134; } function classFromKind(token) { if (isKeyword(token)) { @@ -40579,7 +41294,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5; } - else if (token >= 15 && token <= 66) { + else if (token >= 15 && token <= 68) { return 10; } switch (token) { @@ -40596,7 +41311,7 @@ var ts; case 5: case 4: return 8; - case 67: + case 69: default: if (ts.isTemplateLiteralKind(token)) { return 6; @@ -40622,7 +41337,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 246 ? new SourceFileObject() : new NodeObject(); + var proto = kind === 248 ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = -1; proto.end = -1; @@ -40654,6 +41369,22 @@ var ts; return spaceCache[n]; } server.generateSpaces = generateSpaces; + function generateIndentString(n, editorOptions) { + if (editorOptions.ConvertTabsToSpaces) { + return generateSpaces(n); + } + else { + var result = ""; + for (var i = 0; i < Math.floor(n / editorOptions.TabSize); i++) { + result += "\t"; + } + for (var i = 0; i < n % editorOptions.TabSize; i++) { + result += " "; + } + return result; + } + } + server.generateIndentString = generateIndentString; function compareNumber(a, b) { if (a < b) { return -1; @@ -41265,28 +41996,27 @@ var ts; IndentSize: formatOptions.IndentSize, TabSize: formatOptions.TabSize, NewLineCharacter: "\n", - ConvertTabsToSpaces: formatOptions.ConvertTabsToSpaces + ConvertTabsToSpaces: formatOptions.ConvertTabsToSpaces, + IndentStyle: ts.IndentStyle.Smart }; - var indentPosition = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions); + var preferredIndent = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions); + var hasIndent = 0; for (var i = 0, len = lineText.length; i < len; i++) { if (lineText.charAt(i) == " ") { - indentPosition--; + hasIndent++; } else if (lineText.charAt(i) == "\t") { - indentPosition -= editorOptions.IndentSize; + hasIndent += editorOptions.TabSize; } else { break; } } - if (indentPosition > 0) { - var spaces = generateSpaces(indentPosition); - edits.push({ span: ts.createTextSpanFromBounds(position, position), newText: spaces }); - } - else if (indentPosition < 0) { + if (preferredIndent !== hasIndent) { + var firstNoWhiteSpacePosition = lineInfo.offset + i; edits.push({ - span: ts.createTextSpanFromBounds(position, position - indentPosition), - newText: "" + span: ts.createTextSpanFromBounds(lineInfo.offset, firstNoWhiteSpacePosition), + newText: generateIndentString(preferredIndent, editorOptions) }); } } @@ -41870,6 +42600,9 @@ var ts; this.filenameToSourceFile = {}; this.updateGraphSeq = 0; this.openRefCount = 0; + if (projectOptions && projectOptions.files) { + projectOptions.compilerOptions.allowNonTsExtensions = true; + } this.compilerService = new CompilerService(this, projectOptions && projectOptions.compilerOptions); } Project.prototype.addOpenRef = function () { @@ -41939,6 +42672,7 @@ var ts; Project.prototype.setProjectOptions = function (projectOptions) { this.projectOptions = projectOptions; if (projectOptions.compilerOptions) { + projectOptions.compilerOptions.allowNonTsExtensions = true; this.compilerService.setCompilerOptions(projectOptions.compilerOptions); } }; @@ -42524,7 +43258,9 @@ var ts; this.setCompilerOptions(opt); } else { - this.setCompilerOptions(ts.getDefaultCompilerOptions()); + var defaultOpts = ts.getDefaultCompilerOptions(); + defaultOpts.allowNonTsExtensions = true; + this.setCompilerOptions(defaultOpts); } this.languageService = ts.createLanguageService(this.host, this.documentRegistry); this.classifier = ts.createClassifier(); @@ -42542,6 +43278,7 @@ var ts; TabSize: 4, NewLineCharacter: ts.sys ? ts.sys.newLine : '\n', ConvertTabsToSpaces: true, + IndentStyle: ts.IndentStyle.Smart, InsertSpaceAfterCommaDelimiter: true, InsertSpaceAfterSemicolonInForStatements: true, InsertSpaceBeforeAndAfterBinaryOperators: true, @@ -43485,11 +44222,11 @@ var ts; } fs.stat(watchedFile.fileName, function (err, stats) { if (err) { - watchedFile.callback(watchedFile.fileName); + watchedFile.callback(watchedFile.fileName, false); } else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { watchedFile.mtime = WatchedFileSet.getModifiedTime(watchedFile.fileName); - watchedFile.callback(watchedFile.fileName); + watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0); } }); }; @@ -44135,7 +44872,7 @@ var ts; }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { - var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); + var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), true, true); var convertResult = { referencedFiles: [], importedFiles: [], diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 2cd3a663fcec7..abfa9a002b502 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -68,253 +68,255 @@ declare namespace ts { PlusToken = 35, MinusToken = 36, AsteriskToken = 37, - SlashToken = 38, - PercentToken = 39, - PlusPlusToken = 40, - MinusMinusToken = 41, - LessThanLessThanToken = 42, - GreaterThanGreaterThanToken = 43, - GreaterThanGreaterThanGreaterThanToken = 44, - AmpersandToken = 45, - BarToken = 46, - CaretToken = 47, - ExclamationToken = 48, - TildeToken = 49, - AmpersandAmpersandToken = 50, - BarBarToken = 51, - QuestionToken = 52, - ColonToken = 53, - AtToken = 54, - EqualsToken = 55, - PlusEqualsToken = 56, - MinusEqualsToken = 57, - AsteriskEqualsToken = 58, - SlashEqualsToken = 59, - PercentEqualsToken = 60, - LessThanLessThanEqualsToken = 61, - GreaterThanGreaterThanEqualsToken = 62, - GreaterThanGreaterThanGreaterThanEqualsToken = 63, - AmpersandEqualsToken = 64, - BarEqualsToken = 65, - CaretEqualsToken = 66, - Identifier = 67, - BreakKeyword = 68, - CaseKeyword = 69, - CatchKeyword = 70, - ClassKeyword = 71, - ConstKeyword = 72, - ContinueKeyword = 73, - DebuggerKeyword = 74, - DefaultKeyword = 75, - DeleteKeyword = 76, - DoKeyword = 77, - ElseKeyword = 78, - EnumKeyword = 79, - ExportKeyword = 80, - ExtendsKeyword = 81, - FalseKeyword = 82, - FinallyKeyword = 83, - ForKeyword = 84, - FunctionKeyword = 85, - IfKeyword = 86, - ImportKeyword = 87, - InKeyword = 88, - InstanceOfKeyword = 89, - NewKeyword = 90, - NullKeyword = 91, - ReturnKeyword = 92, - SuperKeyword = 93, - SwitchKeyword = 94, - ThisKeyword = 95, - ThrowKeyword = 96, - TrueKeyword = 97, - TryKeyword = 98, - TypeOfKeyword = 99, - VarKeyword = 100, - VoidKeyword = 101, - WhileKeyword = 102, - WithKeyword = 103, - ImplementsKeyword = 104, - InterfaceKeyword = 105, - LetKeyword = 106, - PackageKeyword = 107, - PrivateKeyword = 108, - ProtectedKeyword = 109, - PublicKeyword = 110, - StaticKeyword = 111, - YieldKeyword = 112, - AbstractKeyword = 113, - AsKeyword = 114, - AnyKeyword = 115, - AsyncKeyword = 116, - AwaitKeyword = 117, - BooleanKeyword = 118, - ConstructorKeyword = 119, - DeclareKeyword = 120, - GetKeyword = 121, - IsKeyword = 122, - ModuleKeyword = 123, - NamespaceKeyword = 124, - RequireKeyword = 125, - NumberKeyword = 126, - SetKeyword = 127, - StringKeyword = 128, - SymbolKeyword = 129, - TypeKeyword = 130, - FromKeyword = 131, - OfKeyword = 132, - QualifiedName = 133, - ComputedPropertyName = 134, - TypeParameter = 135, - Parameter = 136, - Decorator = 137, - PropertySignature = 138, - PropertyDeclaration = 139, - MethodSignature = 140, - MethodDeclaration = 141, - Constructor = 142, - GetAccessor = 143, - SetAccessor = 144, - CallSignature = 145, - ConstructSignature = 146, - IndexSignature = 147, - TypePredicate = 148, - TypeReference = 149, - FunctionType = 150, - ConstructorType = 151, - TypeQuery = 152, - TypeLiteral = 153, - ArrayType = 154, - TupleType = 155, - UnionType = 156, - IntersectionType = 157, - ParenthesizedType = 158, - ObjectBindingPattern = 159, - ArrayBindingPattern = 160, - BindingElement = 161, - ArrayLiteralExpression = 162, - ObjectLiteralExpression = 163, - PropertyAccessExpression = 164, - ElementAccessExpression = 165, - CallExpression = 166, - NewExpression = 167, - TaggedTemplateExpression = 168, - TypeAssertionExpression = 169, - ParenthesizedExpression = 170, - FunctionExpression = 171, - ArrowFunction = 172, - DeleteExpression = 173, - TypeOfExpression = 174, - VoidExpression = 175, - AwaitExpression = 176, - PrefixUnaryExpression = 177, - PostfixUnaryExpression = 178, - BinaryExpression = 179, - ConditionalExpression = 180, - TemplateExpression = 181, - YieldExpression = 182, - SpreadElementExpression = 183, - ClassExpression = 184, - OmittedExpression = 185, - ExpressionWithTypeArguments = 186, - AsExpression = 187, - TemplateSpan = 188, - SemicolonClassElement = 189, - Block = 190, - VariableStatement = 191, - EmptyStatement = 192, - ExpressionStatement = 193, - IfStatement = 194, - DoStatement = 195, - WhileStatement = 196, - ForStatement = 197, - ForInStatement = 198, - ForOfStatement = 199, - ContinueStatement = 200, - BreakStatement = 201, - ReturnStatement = 202, - WithStatement = 203, - SwitchStatement = 204, - LabeledStatement = 205, - ThrowStatement = 206, - TryStatement = 207, - DebuggerStatement = 208, - VariableDeclaration = 209, - VariableDeclarationList = 210, - FunctionDeclaration = 211, - ClassDeclaration = 212, - InterfaceDeclaration = 213, - TypeAliasDeclaration = 214, - EnumDeclaration = 215, - ModuleDeclaration = 216, - ModuleBlock = 217, - CaseBlock = 218, - ImportEqualsDeclaration = 219, - ImportDeclaration = 220, - ImportClause = 221, - NamespaceImport = 222, - NamedImports = 223, - ImportSpecifier = 224, - ExportAssignment = 225, - ExportDeclaration = 226, - NamedExports = 227, - ExportSpecifier = 228, - MissingDeclaration = 229, - ExternalModuleReference = 230, - JsxElement = 231, - JsxSelfClosingElement = 232, - JsxOpeningElement = 233, - JsxText = 234, - JsxClosingElement = 235, - JsxAttribute = 236, - JsxSpreadAttribute = 237, - JsxExpression = 238, - CaseClause = 239, - DefaultClause = 240, - HeritageClause = 241, - CatchClause = 242, - PropertyAssignment = 243, - ShorthandPropertyAssignment = 244, - EnumMember = 245, - SourceFile = 246, - JSDocTypeExpression = 247, - JSDocAllType = 248, - JSDocUnknownType = 249, - JSDocArrayType = 250, - JSDocUnionType = 251, - JSDocTupleType = 252, - JSDocNullableType = 253, - JSDocNonNullableType = 254, - JSDocRecordType = 255, - JSDocRecordMember = 256, - JSDocTypeReference = 257, - JSDocOptionalType = 258, - JSDocFunctionType = 259, - JSDocVariadicType = 260, - JSDocConstructorType = 261, - JSDocThisType = 262, - JSDocComment = 263, - JSDocTag = 264, - JSDocParameterTag = 265, - JSDocReturnTag = 266, - JSDocTypeTag = 267, - JSDocTemplateTag = 268, - SyntaxList = 269, - Count = 270, - FirstAssignment = 55, - LastAssignment = 66, - FirstReservedWord = 68, - LastReservedWord = 103, - FirstKeyword = 68, - LastKeyword = 132, - FirstFutureReservedWord = 104, - LastFutureReservedWord = 112, - FirstTypeNode = 149, - LastTypeNode = 158, + AsteriskAsteriskToken = 38, + SlashToken = 39, + PercentToken = 40, + PlusPlusToken = 41, + MinusMinusToken = 42, + LessThanLessThanToken = 43, + GreaterThanGreaterThanToken = 44, + GreaterThanGreaterThanGreaterThanToken = 45, + AmpersandToken = 46, + BarToken = 47, + CaretToken = 48, + ExclamationToken = 49, + TildeToken = 50, + AmpersandAmpersandToken = 51, + BarBarToken = 52, + QuestionToken = 53, + ColonToken = 54, + AtToken = 55, + EqualsToken = 56, + PlusEqualsToken = 57, + MinusEqualsToken = 58, + AsteriskEqualsToken = 59, + AsteriskAsteriskEqualsToken = 60, + SlashEqualsToken = 61, + PercentEqualsToken = 62, + LessThanLessThanEqualsToken = 63, + GreaterThanGreaterThanEqualsToken = 64, + GreaterThanGreaterThanGreaterThanEqualsToken = 65, + AmpersandEqualsToken = 66, + BarEqualsToken = 67, + CaretEqualsToken = 68, + Identifier = 69, + BreakKeyword = 70, + CaseKeyword = 71, + CatchKeyword = 72, + ClassKeyword = 73, + ConstKeyword = 74, + ContinueKeyword = 75, + DebuggerKeyword = 76, + DefaultKeyword = 77, + DeleteKeyword = 78, + DoKeyword = 79, + ElseKeyword = 80, + EnumKeyword = 81, + ExportKeyword = 82, + ExtendsKeyword = 83, + FalseKeyword = 84, + FinallyKeyword = 85, + ForKeyword = 86, + FunctionKeyword = 87, + IfKeyword = 88, + ImportKeyword = 89, + InKeyword = 90, + InstanceOfKeyword = 91, + NewKeyword = 92, + NullKeyword = 93, + ReturnKeyword = 94, + SuperKeyword = 95, + SwitchKeyword = 96, + ThisKeyword = 97, + ThrowKeyword = 98, + TrueKeyword = 99, + TryKeyword = 100, + TypeOfKeyword = 101, + VarKeyword = 102, + VoidKeyword = 103, + WhileKeyword = 104, + WithKeyword = 105, + ImplementsKeyword = 106, + InterfaceKeyword = 107, + LetKeyword = 108, + PackageKeyword = 109, + PrivateKeyword = 110, + ProtectedKeyword = 111, + PublicKeyword = 112, + StaticKeyword = 113, + YieldKeyword = 114, + AbstractKeyword = 115, + AsKeyword = 116, + AnyKeyword = 117, + AsyncKeyword = 118, + AwaitKeyword = 119, + BooleanKeyword = 120, + ConstructorKeyword = 121, + DeclareKeyword = 122, + GetKeyword = 123, + IsKeyword = 124, + ModuleKeyword = 125, + NamespaceKeyword = 126, + RequireKeyword = 127, + NumberKeyword = 128, + SetKeyword = 129, + StringKeyword = 130, + SymbolKeyword = 131, + TypeKeyword = 132, + FromKeyword = 133, + OfKeyword = 134, + QualifiedName = 135, + ComputedPropertyName = 136, + TypeParameter = 137, + Parameter = 138, + Decorator = 139, + PropertySignature = 140, + PropertyDeclaration = 141, + MethodSignature = 142, + MethodDeclaration = 143, + Constructor = 144, + GetAccessor = 145, + SetAccessor = 146, + CallSignature = 147, + ConstructSignature = 148, + IndexSignature = 149, + TypePredicate = 150, + TypeReference = 151, + FunctionType = 152, + ConstructorType = 153, + TypeQuery = 154, + TypeLiteral = 155, + ArrayType = 156, + TupleType = 157, + UnionType = 158, + IntersectionType = 159, + ParenthesizedType = 160, + ObjectBindingPattern = 161, + ArrayBindingPattern = 162, + BindingElement = 163, + ArrayLiteralExpression = 164, + ObjectLiteralExpression = 165, + PropertyAccessExpression = 166, + ElementAccessExpression = 167, + CallExpression = 168, + NewExpression = 169, + TaggedTemplateExpression = 170, + TypeAssertionExpression = 171, + ParenthesizedExpression = 172, + FunctionExpression = 173, + ArrowFunction = 174, + DeleteExpression = 175, + TypeOfExpression = 176, + VoidExpression = 177, + AwaitExpression = 178, + PrefixUnaryExpression = 179, + PostfixUnaryExpression = 180, + BinaryExpression = 181, + ConditionalExpression = 182, + TemplateExpression = 183, + YieldExpression = 184, + SpreadElementExpression = 185, + ClassExpression = 186, + OmittedExpression = 187, + ExpressionWithTypeArguments = 188, + AsExpression = 189, + TemplateSpan = 190, + SemicolonClassElement = 191, + Block = 192, + VariableStatement = 193, + EmptyStatement = 194, + ExpressionStatement = 195, + IfStatement = 196, + DoStatement = 197, + WhileStatement = 198, + ForStatement = 199, + ForInStatement = 200, + ForOfStatement = 201, + ContinueStatement = 202, + BreakStatement = 203, + ReturnStatement = 204, + WithStatement = 205, + SwitchStatement = 206, + LabeledStatement = 207, + ThrowStatement = 208, + TryStatement = 209, + DebuggerStatement = 210, + VariableDeclaration = 211, + VariableDeclarationList = 212, + FunctionDeclaration = 213, + ClassDeclaration = 214, + InterfaceDeclaration = 215, + TypeAliasDeclaration = 216, + EnumDeclaration = 217, + ModuleDeclaration = 218, + ModuleBlock = 219, + CaseBlock = 220, + ImportEqualsDeclaration = 221, + ImportDeclaration = 222, + ImportClause = 223, + NamespaceImport = 224, + NamedImports = 225, + ImportSpecifier = 226, + ExportAssignment = 227, + ExportDeclaration = 228, + NamedExports = 229, + ExportSpecifier = 230, + MissingDeclaration = 231, + ExternalModuleReference = 232, + JsxElement = 233, + JsxSelfClosingElement = 234, + JsxOpeningElement = 235, + JsxText = 236, + JsxClosingElement = 237, + JsxAttribute = 238, + JsxSpreadAttribute = 239, + JsxExpression = 240, + CaseClause = 241, + DefaultClause = 242, + HeritageClause = 243, + CatchClause = 244, + PropertyAssignment = 245, + ShorthandPropertyAssignment = 246, + EnumMember = 247, + SourceFile = 248, + JSDocTypeExpression = 249, + JSDocAllType = 250, + JSDocUnknownType = 251, + JSDocArrayType = 252, + JSDocUnionType = 253, + JSDocTupleType = 254, + JSDocNullableType = 255, + JSDocNonNullableType = 256, + JSDocRecordType = 257, + JSDocRecordMember = 258, + JSDocTypeReference = 259, + JSDocOptionalType = 260, + JSDocFunctionType = 261, + JSDocVariadicType = 262, + JSDocConstructorType = 263, + JSDocThisType = 264, + JSDocComment = 265, + JSDocTag = 266, + JSDocParameterTag = 267, + JSDocReturnTag = 268, + JSDocTypeTag = 269, + JSDocTemplateTag = 270, + SyntaxList = 271, + Count = 272, + FirstAssignment = 56, + LastAssignment = 68, + FirstReservedWord = 70, + LastReservedWord = 105, + FirstKeyword = 70, + LastKeyword = 134, + FirstFutureReservedWord = 106, + LastFutureReservedWord = 114, + FirstTypeNode = 151, + LastTypeNode = 160, FirstPunctuation = 15, - LastPunctuation = 66, + LastPunctuation = 68, FirstToken = 0, - LastToken = 132, + LastToken = 134, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -322,8 +324,8 @@ declare namespace ts { FirstTemplateToken = 11, LastTemplateToken = 14, FirstBinaryOperator = 25, - LastBinaryOperator = 66, - FirstNode = 133, + LastBinaryOperator = 68, + FirstNode = 135, } const enum NodeFlags { Export = 1, @@ -343,6 +345,7 @@ declare namespace ts { OctalLiteral = 65536, Namespace = 131072, ExportContext = 262144, + ContainsThis = 524288, Modifier = 2035, AccessibilityModifier = 112, BlockScoped = 49152, @@ -438,6 +441,8 @@ declare namespace ts { interface ShorthandPropertyAssignment extends ObjectLiteralElement { name: Identifier; questionToken?: Node; + equalsToken?: Node; + objectAssignmentInitializer?: Expression; } interface VariableLikeDeclaration extends Declaration { propertyName?: Identifier; @@ -530,18 +535,21 @@ declare namespace ts { interface UnaryExpression extends Expression { _unaryExpressionBrand: any; } - interface PrefixUnaryExpression extends UnaryExpression { + interface IncrementExpression extends UnaryExpression { + _incrementExpressionBrand: any; + } + interface PrefixUnaryExpression extends IncrementExpression { operator: SyntaxKind; operand: UnaryExpression; } - interface PostfixUnaryExpression extends PostfixExpression { + interface PostfixUnaryExpression extends IncrementExpression { operand: LeftHandSideExpression; operator: SyntaxKind; } interface PostfixExpression extends UnaryExpression { _postfixExpressionBrand: any; } - interface LeftHandSideExpression extends PostfixExpression { + interface LeftHandSideExpression extends IncrementExpression { _leftHandSideExpressionBrand: any; } interface MemberExpression extends LeftHandSideExpression { @@ -566,7 +574,7 @@ declare namespace ts { asteriskToken?: Node; expression?: Expression; } - interface BinaryExpression extends Expression { + interface BinaryExpression extends Expression, Declaration { left: Expression; operatorToken: Node; right: Expression; @@ -610,7 +618,7 @@ declare namespace ts { interface ObjectLiteralExpression extends PrimaryExpression, Declaration { properties: NodeArray; } - interface PropertyAccessExpression extends MemberExpression { + interface PropertyAccessExpression extends MemberExpression, Declaration { expression: LeftHandSideExpression; dotToken: Node; name: Identifier; @@ -1082,6 +1090,7 @@ declare namespace ts { decreaseIndent(): void; clear(): void; trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; + reportInaccessibleThisError(): void; } const enum TypeFormatFlags { None = 0, @@ -1202,6 +1211,7 @@ declare namespace ts { Instantiated = 131072, ObjectLiteral = 524288, ESSymbol = 16777216, + ThisType = 33554432, StringLike = 258, NumberLike = 132, ObjectType = 80896, @@ -1223,6 +1233,7 @@ declare namespace ts { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; + thisType: TypeParameter; } interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; @@ -1337,7 +1348,6 @@ declare namespace ts { watch?: boolean; isolatedModules?: boolean; experimentalDecorators?: boolean; - experimentalAsyncFunctions?: boolean; emitDecoratorMetadata?: boolean; moduleResolution?: ModuleResolutionKind; [option: string]: string | number | boolean; @@ -1348,6 +1358,7 @@ declare namespace ts { AMD = 2, UMD = 3, System = 4, + ES6 = 5, } const enum JsxEmit { None = 0, @@ -1417,7 +1428,7 @@ declare namespace ts { write(s: string): void; readFile(path: string, encoding?: string): string; writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; - watchFile?(path: string, callback: (path: string) => void): FileWatcher; + watchFile?(path: string, callback: (path: string, removed: boolean) => void): FileWatcher; resolvePath(path: string): string; fileExists(path: string): boolean; directoryExists(path: string): boolean; @@ -1775,6 +1786,12 @@ declare namespace ts { TabSize: number; NewLineCharacter: string; ConvertTabsToSpaces: boolean; + IndentStyle: IndentStyle; + } + enum IndentStyle { + None = 0, + Block = 1, + Smart = 2, } interface FormatCodeOptions extends EditorOptions { InsertSpaceAfterCommaDelimiter: boolean; @@ -2132,7 +2149,7 @@ declare namespace ts { function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string; function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; - function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; + function preProcessFile(sourceText: string, readImportFiles?: boolean, detectJavaScriptImports?: boolean): PreProcessedFileInfo; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; function createClassifier(): Classifier; /** diff --git a/lib/typescript.js b/lib/typescript.js index a1f9651570e18..d261ce125fc65 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -62,279 +62,281 @@ var ts; SyntaxKind[SyntaxKind["PlusToken"] = 35] = "PlusToken"; SyntaxKind[SyntaxKind["MinusToken"] = 36] = "MinusToken"; SyntaxKind[SyntaxKind["AsteriskToken"] = 37] = "AsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 38] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 39] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 40] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 41] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 42] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 43] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 44] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 45] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 46] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 47] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 48] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 49] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 50] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 51] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 52] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 53] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 54] = "AtToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 38] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 39] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 40] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 41] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 42] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 43] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 44] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 46] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 47] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 48] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 49] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 50] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 51] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 52] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 53] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 54] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 55] = "AtToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 55] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 56] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 57] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 58] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 59] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 60] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 61] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 62] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 63] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 64] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 65] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 66] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 56] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 57] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 58] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 59] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 60] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 61] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 62] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 63] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 64] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 66] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 67] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 68] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 67] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 69] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 68] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 69] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 70] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 71] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 72] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 73] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 74] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 75] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 76] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 77] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 78] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 79] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 80] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 81] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 82] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 83] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 84] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 85] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 86] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 87] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 88] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 89] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 90] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 91] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 92] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 93] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 94] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 95] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 96] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 97] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 98] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 99] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 100] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 101] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 102] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 103] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 70] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 71] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 72] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 73] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 74] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 75] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 76] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 77] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 78] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 79] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 80] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 81] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 82] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 83] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 84] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 85] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 86] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 87] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 88] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 89] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 90] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 91] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 92] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 93] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 94] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 95] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 96] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 97] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 98] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 99] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 100] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 101] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 102] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 103] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 104] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 105] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 104] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 105] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 106] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 107] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 108] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 109] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 110] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 111] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 112] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 106] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 107] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 108] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 109] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 110] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 111] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 112] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 113] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 114] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 113] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 114] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 115] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 116] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 117] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 118] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 119] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 120] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 121] = "GetKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 122] = "IsKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 123] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 124] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 125] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 126] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 127] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 128] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 129] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 130] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 131] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 132] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 115] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 116] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 117] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 118] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 119] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 120] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 121] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 122] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 123] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 124] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 125] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 126] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 127] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 128] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 129] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 130] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 131] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 132] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 133] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 134] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 133] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 134] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 135] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 136] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 135] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 136] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 137] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 137] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 138] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 139] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 138] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 139] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 140] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 141] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 142] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 143] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 144] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 145] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 146] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 147] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 140] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 141] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 142] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 143] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 144] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 145] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 146] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 147] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 148] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 149] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 148] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 149] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 150] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 151] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 152] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 153] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 154] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 155] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 156] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 157] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 158] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 150] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 151] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 152] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 153] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 154] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 155] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 156] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 157] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 158] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 159] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 160] = "ParenthesizedType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 159] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 160] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 161] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 161] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 162] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 163] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 162] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 163] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 164] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 165] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 166] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 167] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 168] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 169] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 170] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 171] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 172] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 173] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 174] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 175] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 176] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 177] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 178] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 179] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 180] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 181] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 182] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 183] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 184] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 185] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 186] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 187] = "AsExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 164] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 165] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 166] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 167] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 168] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 169] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 170] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 171] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 172] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 173] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 174] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 175] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 176] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 177] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 178] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 179] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 180] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 181] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 182] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 183] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 184] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 185] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 186] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 187] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 188] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 189] = "AsExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 188] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 189] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 190] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 191] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 190] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 191] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 192] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 193] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 194] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 195] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 196] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 197] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 198] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 199] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 200] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 201] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 202] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 203] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 204] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 205] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 206] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 207] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 208] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 209] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 210] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 211] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 212] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 213] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 214] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 215] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 216] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 217] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 218] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 219] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 220] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 221] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 222] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 223] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 224] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 225] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 226] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 227] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 228] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 229] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 192] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 193] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 194] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 195] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 196] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 197] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 198] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 199] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 200] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 201] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 202] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 203] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 204] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 205] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 206] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 207] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 208] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 209] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 210] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 211] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 212] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 213] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 214] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 215] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 216] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 217] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 218] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 219] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 220] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 221] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 222] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 223] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 224] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 225] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 226] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 227] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 228] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 229] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 230] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 231] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 230] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 232] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 231] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 232] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 233] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxText"] = 234] = "JsxText"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 235] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 236] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 237] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 238] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 233] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 234] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 235] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxText"] = 236] = "JsxText"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 237] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 238] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 239] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 240] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 239] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 240] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 241] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 242] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 241] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 242] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 243] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 244] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 243] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 244] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 245] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 246] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 245] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 247] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 246] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 248] = "SourceFile"; // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 247] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 249] = "JSDocTypeExpression"; // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 248] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 250] = "JSDocAllType"; // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 249] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 250] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 251] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 252] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 253] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 254] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 255] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 256] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 257] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 258] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 259] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 260] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 261] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 262] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 263] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 264] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 265] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 266] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 267] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 268] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 251] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 252] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 253] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 254] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 255] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 256] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 257] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 258] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 259] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 260] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 261] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 262] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 263] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 264] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 265] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 266] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 267] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 268] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 269] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 270] = "JSDocTemplateTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 269] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 271] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 270] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 272] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 55] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 66] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 68] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 103] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 68] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 132] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 104] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 112] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 149] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 158] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 56] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 68] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 70] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 105] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 70] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 134] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 106] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 114] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 151] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 160] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 66] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 68] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 132] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 134] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -342,8 +344,8 @@ var ts; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 11] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 14] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 25] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 66] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 133] = "FirstNode"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 68] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 135] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -364,6 +366,7 @@ var ts; NodeFlags[NodeFlags["OctalLiteral"] = 65536] = "OctalLiteral"; NodeFlags[NodeFlags["Namespace"] = 131072] = "Namespace"; NodeFlags[NodeFlags["ExportContext"] = 262144] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 524288] = "ContainsThis"; NodeFlags[NodeFlags["Modifier"] = 2035] = "Modifier"; NodeFlags[NodeFlags["AccessibilityModifier"] = 112] = "AccessibilityModifier"; NodeFlags[NodeFlags["BlockScoped"] = 49152] = "BlockScoped"; @@ -613,6 +616,7 @@ var ts; /* @internal */ TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; TypeFlags[TypeFlags["ESSymbol"] = 16777216] = "ESSymbol"; + TypeFlags[TypeFlags["ThisType"] = 33554432] = "ThisType"; /* @internal */ TypeFlags[TypeFlags["Intrinsic"] = 16777343] = "Intrinsic"; /* @internal */ @@ -655,6 +659,7 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; + ModuleKind[ModuleKind["ES6"] = 5] = "ES6"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; (function (JsxEmit) { @@ -1221,8 +1226,11 @@ var ts; } ts.chainDiagnosticMessages = chainDiagnosticMessages; function concatenateDiagnosticMessageChains(headChain, tailChain) { - Debug.assert(!headChain.next); - headChain.next = tailChain; + var lastChain = headChain; + while (lastChain.next) { + lastChain = lastChain.next; + } + lastChain.next = tailChain; return headChain; } ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; @@ -1496,6 +1504,7 @@ var ts; * List of supported extensions in order of file resolution precedence. */ ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; + ts.supportedJsExtensions = ts.supportedExtensions.concat(".js", ".jsx"); var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { @@ -1819,10 +1828,15 @@ var ts; close: function () { _fs.unwatchFile(fileName, fileChanged); } }; function fileChanged(curr, prev) { + // mtime.getTime() equals 0 if file was removed + if (curr.mtime.getTime() === 0) { + callback(fileName, /* removed */ true); + return; + } if (+curr.mtime <= +prev.mtime) { return; } - callback(fileName); + callback(fileName, /* removed */ false); } }, resolvePath: function (path) { @@ -1925,7 +1939,7 @@ var ts; Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum member must have initializer." }, _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, - 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." }, + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In ambient enum declarations member initializer must be constant expression." }, 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_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, @@ -2013,7 +2027,7 @@ var ts; 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." }, - An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, + An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1183, 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." }, @@ -2031,10 +2045,9 @@ var ts; 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." }, - 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_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' 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." }, + Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." }, + Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." }, + Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es6' when targeting 'ES5' or lower." }, 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." }, Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, @@ -2063,10 +2076,6 @@ var ts; An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, - Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning: { code: 1236, category: ts.DiagnosticCategory.Error, key: "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning." }, - with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, - await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, - Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, @@ -2077,6 +2086,10 @@ var ts; _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." }, Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." }, Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method '{0}' cannot have an implementation because it is marked abstract." }, + with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, + await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, + Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, + can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "'=' can only be used in an object literal property inside a destructuring assignment." }, 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." }, @@ -2201,7 +2214,7 @@ var ts; 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_namespace_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 namespace declaration cannot be in a different file from a class or function with which it is merged" }, A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules." }, + Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules or namespaces." }, Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient 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}'" }, @@ -2289,6 +2302,9 @@ var ts; yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." }, + A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A 'this' type is available only in a non-static member of a class or interface." }, + The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, + A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A module cannot have multiple default exports." }, JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2389,7 +2405,7 @@ var ts; Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, - A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, 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." }, @@ -2401,7 +2417,7 @@ var ts; 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_amd_system_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'" }, + Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es6'" }, 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." }, @@ -2422,7 +2438,7 @@ var ts; 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_amd_system_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'." }, + Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es6'." }, 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}'." }, @@ -2443,7 +2459,6 @@ var ts; Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, - Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, @@ -2490,7 +2505,9 @@ var ts; Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" }, + An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, + A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." } }; })(ts || (ts = {})); /// @@ -2499,75 +2516,75 @@ var ts; (function (ts) { /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 67 /* Identifier */; + return token >= 69 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = { - "abstract": 113 /* AbstractKeyword */, - "any": 115 /* AnyKeyword */, - "as": 114 /* AsKeyword */, - "boolean": 118 /* BooleanKeyword */, - "break": 68 /* BreakKeyword */, - "case": 69 /* CaseKeyword */, - "catch": 70 /* CatchKeyword */, - "class": 71 /* ClassKeyword */, - "continue": 73 /* ContinueKeyword */, - "const": 72 /* ConstKeyword */, - "constructor": 119 /* ConstructorKeyword */, - "debugger": 74 /* DebuggerKeyword */, - "declare": 120 /* DeclareKeyword */, - "default": 75 /* DefaultKeyword */, - "delete": 76 /* DeleteKeyword */, - "do": 77 /* DoKeyword */, - "else": 78 /* ElseKeyword */, - "enum": 79 /* EnumKeyword */, - "export": 80 /* ExportKeyword */, - "extends": 81 /* ExtendsKeyword */, - "false": 82 /* FalseKeyword */, - "finally": 83 /* FinallyKeyword */, - "for": 84 /* ForKeyword */, - "from": 131 /* FromKeyword */, - "function": 85 /* FunctionKeyword */, - "get": 121 /* GetKeyword */, - "if": 86 /* IfKeyword */, - "implements": 104 /* ImplementsKeyword */, - "import": 87 /* ImportKeyword */, - "in": 88 /* InKeyword */, - "instanceof": 89 /* InstanceOfKeyword */, - "interface": 105 /* InterfaceKeyword */, - "is": 122 /* IsKeyword */, - "let": 106 /* LetKeyword */, - "module": 123 /* ModuleKeyword */, - "namespace": 124 /* NamespaceKeyword */, - "new": 90 /* NewKeyword */, - "null": 91 /* NullKeyword */, - "number": 126 /* NumberKeyword */, - "package": 107 /* PackageKeyword */, - "private": 108 /* PrivateKeyword */, - "protected": 109 /* ProtectedKeyword */, - "public": 110 /* PublicKeyword */, - "require": 125 /* RequireKeyword */, - "return": 92 /* ReturnKeyword */, - "set": 127 /* SetKeyword */, - "static": 111 /* StaticKeyword */, - "string": 128 /* StringKeyword */, - "super": 93 /* SuperKeyword */, - "switch": 94 /* SwitchKeyword */, - "symbol": 129 /* SymbolKeyword */, - "this": 95 /* ThisKeyword */, - "throw": 96 /* ThrowKeyword */, - "true": 97 /* TrueKeyword */, - "try": 98 /* TryKeyword */, - "type": 130 /* TypeKeyword */, - "typeof": 99 /* TypeOfKeyword */, - "var": 100 /* VarKeyword */, - "void": 101 /* VoidKeyword */, - "while": 102 /* WhileKeyword */, - "with": 103 /* WithKeyword */, - "yield": 112 /* YieldKeyword */, - "async": 116 /* AsyncKeyword */, - "await": 117 /* AwaitKeyword */, - "of": 132 /* OfKeyword */, + "abstract": 115 /* AbstractKeyword */, + "any": 117 /* AnyKeyword */, + "as": 116 /* AsKeyword */, + "boolean": 120 /* BooleanKeyword */, + "break": 70 /* BreakKeyword */, + "case": 71 /* CaseKeyword */, + "catch": 72 /* CatchKeyword */, + "class": 73 /* ClassKeyword */, + "continue": 75 /* ContinueKeyword */, + "const": 74 /* ConstKeyword */, + "constructor": 121 /* ConstructorKeyword */, + "debugger": 76 /* DebuggerKeyword */, + "declare": 122 /* DeclareKeyword */, + "default": 77 /* DefaultKeyword */, + "delete": 78 /* DeleteKeyword */, + "do": 79 /* DoKeyword */, + "else": 80 /* ElseKeyword */, + "enum": 81 /* EnumKeyword */, + "export": 82 /* ExportKeyword */, + "extends": 83 /* ExtendsKeyword */, + "false": 84 /* FalseKeyword */, + "finally": 85 /* FinallyKeyword */, + "for": 86 /* ForKeyword */, + "from": 133 /* FromKeyword */, + "function": 87 /* FunctionKeyword */, + "get": 123 /* GetKeyword */, + "if": 88 /* IfKeyword */, + "implements": 106 /* ImplementsKeyword */, + "import": 89 /* ImportKeyword */, + "in": 90 /* InKeyword */, + "instanceof": 91 /* InstanceOfKeyword */, + "interface": 107 /* InterfaceKeyword */, + "is": 124 /* IsKeyword */, + "let": 108 /* LetKeyword */, + "module": 125 /* ModuleKeyword */, + "namespace": 126 /* NamespaceKeyword */, + "new": 92 /* NewKeyword */, + "null": 93 /* NullKeyword */, + "number": 128 /* NumberKeyword */, + "package": 109 /* PackageKeyword */, + "private": 110 /* PrivateKeyword */, + "protected": 111 /* ProtectedKeyword */, + "public": 112 /* PublicKeyword */, + "require": 127 /* RequireKeyword */, + "return": 94 /* ReturnKeyword */, + "set": 129 /* SetKeyword */, + "static": 113 /* StaticKeyword */, + "string": 130 /* StringKeyword */, + "super": 95 /* SuperKeyword */, + "switch": 96 /* SwitchKeyword */, + "symbol": 131 /* SymbolKeyword */, + "this": 97 /* ThisKeyword */, + "throw": 98 /* ThrowKeyword */, + "true": 99 /* TrueKeyword */, + "try": 100 /* TryKeyword */, + "type": 132 /* TypeKeyword */, + "typeof": 101 /* TypeOfKeyword */, + "var": 102 /* VarKeyword */, + "void": 103 /* VoidKeyword */, + "while": 104 /* WhileKeyword */, + "with": 105 /* WithKeyword */, + "yield": 114 /* YieldKeyword */, + "async": 118 /* AsyncKeyword */, + "await": 119 /* AwaitKeyword */, + "of": 134 /* OfKeyword */, "{": 15 /* OpenBraceToken */, "}": 16 /* CloseBraceToken */, "(": 17 /* OpenParenToken */, @@ -2589,37 +2606,39 @@ var ts; "=>": 34 /* EqualsGreaterThanToken */, "+": 35 /* PlusToken */, "-": 36 /* MinusToken */, + "**": 38 /* AsteriskAsteriskToken */, "*": 37 /* AsteriskToken */, - "/": 38 /* SlashToken */, - "%": 39 /* PercentToken */, - "++": 40 /* PlusPlusToken */, - "--": 41 /* MinusMinusToken */, - "<<": 42 /* LessThanLessThanToken */, + "/": 39 /* SlashToken */, + "%": 40 /* PercentToken */, + "++": 41 /* PlusPlusToken */, + "--": 42 /* MinusMinusToken */, + "<<": 43 /* LessThanLessThanToken */, ">": 43 /* GreaterThanGreaterThanToken */, - ">>>": 44 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 45 /* AmpersandToken */, - "|": 46 /* BarToken */, - "^": 47 /* CaretToken */, - "!": 48 /* ExclamationToken */, - "~": 49 /* TildeToken */, - "&&": 50 /* AmpersandAmpersandToken */, - "||": 51 /* BarBarToken */, - "?": 52 /* QuestionToken */, - ":": 53 /* ColonToken */, - "=": 55 /* EqualsToken */, - "+=": 56 /* PlusEqualsToken */, - "-=": 57 /* MinusEqualsToken */, - "*=": 58 /* AsteriskEqualsToken */, - "/=": 59 /* SlashEqualsToken */, - "%=": 60 /* PercentEqualsToken */, - "<<=": 61 /* LessThanLessThanEqualsToken */, - ">>=": 62 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 64 /* AmpersandEqualsToken */, - "|=": 65 /* BarEqualsToken */, - "^=": 66 /* CaretEqualsToken */, - "@": 54 /* AtToken */ + ">>": 44 /* GreaterThanGreaterThanToken */, + ">>>": 45 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 46 /* AmpersandToken */, + "|": 47 /* BarToken */, + "^": 48 /* CaretToken */, + "!": 49 /* ExclamationToken */, + "~": 50 /* TildeToken */, + "&&": 51 /* AmpersandAmpersandToken */, + "||": 52 /* BarBarToken */, + "?": 53 /* QuestionToken */, + ":": 54 /* ColonToken */, + "=": 56 /* EqualsToken */, + "+=": 57 /* PlusEqualsToken */, + "-=": 58 /* MinusEqualsToken */, + "*=": 59 /* AsteriskEqualsToken */, + "**=": 60 /* AsteriskAsteriskEqualsToken */, + "/=": 61 /* SlashEqualsToken */, + "%=": 62 /* PercentEqualsToken */, + "<<=": 63 /* LessThanLessThanEqualsToken */, + ">>=": 64 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 66 /* AmpersandEqualsToken */, + "|=": 67 /* BarEqualsToken */, + "^=": 68 /* CaretEqualsToken */, + "@": 55 /* AtToken */ }; /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers @@ -3123,8 +3142,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 67 /* Identifier */ || token > 103 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 68 /* FirstReservedWord */ && token <= 103 /* LastReservedWord */; }, + isIdentifier: function () { return token === 69 /* Identifier */ || token > 105 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 70 /* FirstReservedWord */ && token <= 105 /* LastReservedWord */; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -3146,16 +3165,6 @@ var ts; onError(message, length || 0); } } - function isIdentifierStart(ch) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); - } - function isIdentifierPart(ch) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); - } function scanNumber() { var start = pos; while (isDigit(text.charCodeAt(pos))) @@ -3438,12 +3447,12 @@ var ts; var start = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (isIdentifierPart(ch)) { + if (isIdentifierPart(ch, languageVersion)) { pos++; } else if (ch === 92 /* backslash */) { ch = peekUnicodeEscape(); - if (!(ch >= 0 && isIdentifierPart(ch))) { + if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } result += text.substring(start, pos); @@ -3468,7 +3477,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 67 /* Identifier */; + return token = 69 /* Identifier */; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -3552,7 +3561,7 @@ var ts; } return pos += 2, token = 31 /* ExclamationEqualsToken */; } - return pos++, token = 48 /* ExclamationToken */; + return pos++, token = 49 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -3561,42 +3570,48 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 60 /* PercentEqualsToken */; + return pos += 2, token = 62 /* PercentEqualsToken */; } - return pos++, token = 39 /* PercentToken */; + return pos++, token = 40 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 50 /* AmpersandAmpersandToken */; + return pos += 2, token = 51 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* AmpersandEqualsToken */; + return pos += 2, token = 66 /* AmpersandEqualsToken */; } - return pos++, token = 45 /* AmpersandToken */; + return pos++, token = 46 /* AmpersandToken */; case 40 /* openParen */: return pos++, token = 17 /* OpenParenToken */; case 41 /* closeParen */: return pos++, token = 18 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* AsteriskEqualsToken */; + return pos += 2, token = 59 /* AsteriskEqualsToken */; + } + if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 2) === 61 /* equals */) { + return pos += 3, token = 60 /* AsteriskAsteriskEqualsToken */; + } + return pos += 2, token = 38 /* AsteriskAsteriskToken */; } return pos++, token = 37 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 40 /* PlusPlusToken */; + return pos += 2, token = 41 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 56 /* PlusEqualsToken */; + return pos += 2, token = 57 /* PlusEqualsToken */; } return pos++, token = 35 /* PlusToken */; case 44 /* comma */: return pos++, token = 24 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 41 /* MinusMinusToken */; + return pos += 2, token = 42 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 57 /* MinusEqualsToken */; + return pos += 2, token = 58 /* MinusEqualsToken */; } return pos++, token = 36 /* MinusToken */; case 46 /* dot */: @@ -3653,9 +3668,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* SlashEqualsToken */; + return pos += 2, token = 61 /* SlashEqualsToken */; } - return pos++, token = 38 /* SlashToken */; + return pos++, token = 39 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -3707,7 +3722,7 @@ var ts; tokenValue = "" + scanNumber(); return token = 8 /* NumericLiteral */; case 58 /* colon */: - return pos++, token = 53 /* ColonToken */; + return pos++, token = 54 /* ColonToken */; case 59 /* semicolon */: return pos++, token = 23 /* SemicolonToken */; case 60 /* lessThan */: @@ -3722,14 +3737,16 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 61 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 63 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 42 /* LessThanLessThanToken */; + return pos += 2, token = 43 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { return pos += 2, token = 28 /* LessThanEqualsToken */; } - if (text.charCodeAt(pos + 1) === 47 /* slash */ && languageVariant === 1 /* JSX */) { + if (languageVariant === 1 /* JSX */ && + text.charCodeAt(pos + 1) === 47 /* slash */ && + text.charCodeAt(pos + 2) !== 42 /* asterisk */) { return pos += 2, token = 26 /* LessThanSlashToken */; } return pos++, token = 25 /* LessThanToken */; @@ -3752,7 +3769,7 @@ var ts; if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { return pos += 2, token = 34 /* EqualsGreaterThanToken */; } - return pos++, token = 55 /* EqualsToken */; + return pos++, token = 56 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3765,35 +3782,35 @@ var ts; } return pos++, token = 27 /* GreaterThanToken */; case 63 /* question */: - return pos++, token = 52 /* QuestionToken */; + return pos++, token = 53 /* QuestionToken */; case 91 /* openBracket */: return pos++, token = 19 /* OpenBracketToken */; case 93 /* closeBracket */: return pos++, token = 20 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* CaretEqualsToken */; + return pos += 2, token = 68 /* CaretEqualsToken */; } - return pos++, token = 47 /* CaretToken */; + return pos++, token = 48 /* CaretToken */; case 123 /* openBrace */: return pos++, token = 15 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 51 /* BarBarToken */; + return pos += 2, token = 52 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* BarEqualsToken */; + return pos += 2, token = 67 /* BarEqualsToken */; } - return pos++, token = 46 /* BarToken */; + return pos++, token = 47 /* BarToken */; case 125 /* closeBrace */: return pos++, token = 16 /* CloseBraceToken */; case 126 /* tilde */: - return pos++, token = 49 /* TildeToken */; + return pos++, token = 50 /* TildeToken */; case 64 /* at */: - return pos++, token = 54 /* AtToken */; + return pos++, token = 55 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); @@ -3801,9 +3818,9 @@ var ts; error(ts.Diagnostics.Invalid_character); return pos++, token = 0 /* Unknown */; default: - if (isIdentifierStart(ch)) { + if (isIdentifierStart(ch, languageVersion)) { pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos))) + while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) pos++; tokenValue = text.substring(tokenPos, pos); if (ch === 92 /* backslash */) { @@ -3830,14 +3847,14 @@ var ts; if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 44 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 45 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 64 /* GreaterThanGreaterThanEqualsToken */; } - return pos++, token = 43 /* GreaterThanGreaterThanToken */; + return pos++, token = 44 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { return pos++, token = 29 /* GreaterThanEqualsToken */; @@ -3846,7 +3863,7 @@ var ts; return token; } function reScanSlashToken() { - if (token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) { + if (token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -3886,7 +3903,7 @@ var ts; } p++; } - while (p < end && isIdentifierPart(text.charCodeAt(p))) { + while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { p++; } pos = p; @@ -3932,7 +3949,7 @@ var ts; break; } } - return token = 234 /* JsxText */; + return token = 236 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -3941,7 +3958,7 @@ var ts; var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) { + if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { pos++; } else { @@ -4020,16 +4037,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 214 /* TypeAliasDeclaration */) { + if (node.kind === 215 /* InterfaceDeclaration */ || node.kind === 216 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 217 /* ModuleBlock */) { + else if (node.kind === 219 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -4048,7 +4065,7 @@ var ts; }); return state; } - else if (node.kind === 216 /* ModuleDeclaration */) { + else if (node.kind === 218 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -4088,6 +4105,8 @@ var ts; var container; var blockScopeContainer; var lastContainer; + var seenThisKeyword; + var isJavaScriptFile = ts.isSourceFileJavaScript(file); // If this file is an external module, then it is automatically in strict-mode according to // ES6. If it is not an external module, then we'll determine if it is in strict mode or // not depending on if we see "use strict" in certain places (or if we hit a class/namespace). @@ -4126,10 +4145,10 @@ var ts; // unless it is a well known Symbol. function getDeclarationName(node) { if (node.name) { - if (node.kind === 216 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 218 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return "\"" + node.name.text + "\""; } - if (node.name.kind === 134 /* ComputedPropertyName */) { + if (node.name.kind === 136 /* ComputedPropertyName */) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -4137,22 +4156,25 @@ var ts; return node.name.text; } switch (node.kind) { - case 142 /* Constructor */: + case 144 /* Constructor */: return "__constructor"; - case 150 /* FunctionType */: - case 145 /* CallSignature */: + case 152 /* FunctionType */: + case 147 /* CallSignature */: return "__call"; - case 151 /* ConstructorType */: - case 146 /* ConstructSignature */: + case 153 /* ConstructorType */: + case 148 /* ConstructSignature */: return "__new"; - case 147 /* IndexSignature */: + case 149 /* IndexSignature */: return "__index"; - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return "__export"; - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 211 /* FunctionDeclaration */: - case 212 /* ClassDeclaration */: + case 181 /* BinaryExpression */: + // Binary expression case is for JS module 'module.exports = expr' + return "export="; + case 213 /* FunctionDeclaration */: + case 214 /* ClassDeclaration */: return node.flags & 1024 /* Default */ ? "default" : undefined; } } @@ -4169,8 +4191,9 @@ var ts; */ function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); + var isDefaultExport = node.flags & 1024 /* Default */; // The exported symbol for an export default function/class node is always named "default" - var name = node.flags & 1024 /* Default */ && parent ? "default" : getDeclarationName(node); + var name = isDefaultExport && parent ? "default" : getDeclarationName(node); var symbol; if (name !== undefined) { // Check and see if the symbol table already has a symbol with this name. If not, @@ -4206,6 +4229,11 @@ var ts; var message = symbol.flags & 2 /* BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; + ts.forEach(symbol.declarations, function (declaration) { + if (declaration.flags & 1024 /* Default */) { + message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + } + }); ts.forEach(symbol.declarations, function (declaration) { file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); }); @@ -4223,7 +4251,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 228 /* ExportSpecifier */ || (node.kind === 219 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 230 /* ExportSpecifier */ || (node.kind === 221 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -4297,44 +4325,51 @@ var ts; blockScopeContainer = node; blockScopeContainer.locals = undefined; } - ts.forEachChild(node, bind); + if (node.kind === 215 /* InterfaceDeclaration */) { + seenThisKeyword = false; + ts.forEachChild(node, bind); + node.flags = seenThisKeyword ? node.flags | 524288 /* ContainsThis */ : node.flags & ~524288 /* ContainsThis */; + } + else { + ts.forEachChild(node, bind); + } container = saveContainer; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } function getContainerFlags(node) { switch (node.kind) { - case 184 /* ClassExpression */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 153 /* TypeLiteral */: - case 163 /* ObjectLiteralExpression */: + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 155 /* TypeLiteral */: + case 165 /* ObjectLiteralExpression */: return 1 /* IsContainer */; - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 211 /* FunctionDeclaration */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 216 /* ModuleDeclaration */: - case 246 /* SourceFile */: - case 214 /* TypeAliasDeclaration */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 213 /* FunctionDeclaration */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 218 /* ModuleDeclaration */: + case 248 /* SourceFile */: + case 216 /* TypeAliasDeclaration */: return 5 /* IsContainerWithLocals */; - case 242 /* CatchClause */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 218 /* CaseBlock */: + case 244 /* CatchClause */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 220 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 190 /* Block */: + case 192 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Othewise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -4371,38 +4406,38 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 246 /* SourceFile */: + case 248 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 184 /* ClassExpression */: - case 212 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 153 /* TypeLiteral */: - case 163 /* ObjectLiteralExpression */: - case 213 /* InterfaceDeclaration */: + case 155 /* TypeLiteral */: + case 165 /* ObjectLiteralExpression */: + case 215 /* InterfaceDeclaration */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 214 /* TypeAliasDeclaration */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 216 /* TypeAliasDeclaration */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -4432,11 +4467,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 246 /* SourceFile */ ? node : node.body; - if (body.kind === 246 /* SourceFile */ || body.kind === 217 /* ModuleBlock */) { + var body = node.kind === 248 /* SourceFile */ ? node : node.body; + if (body.kind === 248 /* SourceFile */ || body.kind === 219 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 226 /* ExportDeclaration */ || stat.kind === 225 /* ExportAssignment */) { + if (stat.kind === 228 /* ExportDeclaration */ || stat.kind === 227 /* ExportAssignment */) { return true; } } @@ -4508,7 +4543,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 67 /* Identifier */) { + if (prop.name.kind !== 69 /* Identifier */) { continue; } var identifier = prop.name; @@ -4520,7 +4555,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */ || prop.kind === 141 /* MethodDeclaration */ + var currentKind = prop.kind === 245 /* PropertyAssignment */ || prop.kind === 246 /* ShorthandPropertyAssignment */ || prop.kind === 143 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -4542,10 +4577,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 246 /* SourceFile */: + case 248 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -4566,8 +4601,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 104 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 112 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 106 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 114 /* LastFutureReservedWord */ && !ts.isIdentifierName(node)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { @@ -4602,7 +4637,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 67 /* Identifier */) { + if (inStrictMode && node.expression.kind === 69 /* Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -4610,11 +4645,11 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 67 /* Identifier */ && + return node.kind === 69 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 67 /* Identifier */) { + if (name && name.kind === 69 /* Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -4658,7 +4693,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 40 /* PlusPlusToken */ || node.operator === 41 /* MinusMinusToken */) { + if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -4702,17 +4737,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 246 /* SourceFile */: - case 217 /* ModuleBlock */: + case 248 /* SourceFile */: + case 219 /* ModuleBlock */: updateStrictModeStatementList(node.statements); return; - case 190 /* Block */: + case 192 /* Block */: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return; @@ -4739,107 +4774,130 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 67 /* Identifier */: + /* Strict mode checks */ + case 69 /* Identifier */: return checkStrictModeIdentifier(node); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: + if (isJavaScriptFile) { + if (ts.isExportsPropertyAssignment(node)) { + bindExportsPropertyAssignment(node); + } + else if (ts.isModuleExportsAssignment(node)) { + bindModuleExportsAssignment(node); + } + } return checkStrictModeBinaryExpression(node); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return checkStrictModeCatchClause(node); - case 173 /* DeleteExpression */: + case 175 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 178 /* PostfixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 203 /* WithStatement */: + case 205 /* WithStatement */: return checkStrictModeWithStatement(node); - case 135 /* TypeParameter */: + case 97 /* ThisKeyword */: + seenThisKeyword = true; + return; + case 137 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 136 /* Parameter */: + case 138 /* Parameter */: return bindParameter(node); - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 243 /* PropertyAssignment */: - case 244 /* ShorthandPropertyAssignment */: + case 245 /* PropertyAssignment */: + case 246 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 245 /* EnumMember */: + case 247 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); - case 142 /* Constructor */: + case 144 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 143 /* GetAccessor */: + case 145 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 144 /* SetAccessor */: + case 146 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 153 /* TypeLiteral */: + case 155 /* TypeLiteral */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); - case 184 /* ClassExpression */: - case 212 /* ClassDeclaration */: + case 168 /* CallExpression */: + if (isJavaScriptFile) { + bindCallExpression(node); + } + break; + // Members of classes, interfaces, and modules + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: return bindClassLikeDeclaration(node); - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */); - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return bindModuleDeclaration(node); - case 219 /* ImportEqualsDeclaration */: - case 222 /* NamespaceImport */: - case 224 /* ImportSpecifier */: - case 228 /* ExportSpecifier */: + // Imports and exports + case 221 /* ImportEqualsDeclaration */: + case 224 /* NamespaceImport */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 221 /* ImportClause */: + case 223 /* ImportClause */: return bindImportClause(node); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return bindExportDeclaration(node); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return bindExportAssignment(node); - case 246 /* SourceFile */: + case 248 /* SourceFile */: return bindSourceFileIfExternalModule(); } } function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); + bindSourceFileAsExternalModule(); } } + function bindSourceFileAsExternalModule() { + bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); + } function bindExportAssignment(node) { + var boundExpression = node.kind === 227 /* ExportAssignment */ ? node.expression : node.right; if (!container.symbol || !container.symbol.exports) { // Export assignment in some sort of block construct bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); } - else if (node.expression.kind === 67 /* Identifier */) { + else if (boundExpression.kind === 69 /* Identifier */) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* Alias */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); } @@ -4863,8 +4921,32 @@ var ts; declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); } } + function setCommonJsModuleIndicator(node) { + if (!file.commonJsModuleIndicator) { + file.commonJsModuleIndicator = node; + bindSourceFileAsExternalModule(); + } + } + function bindExportsPropertyAssignment(node) { + // When we create a property via 'exports.foo = bar', the 'exports.foo' property access + // expression is the declaration + setCommonJsModuleIndicator(node); + declareSymbol(file.symbol.exports, file.symbol, node.left, 4 /* Property */ | 7340032 /* Export */, 0 /* None */); + } + function bindModuleExportsAssignment(node) { + // 'module.exports = expr' assignment + setCommonJsModuleIndicator(node); + bindExportAssignment(node); + } + function bindCallExpression(node) { + // We're only inspecting call expressions to detect CommonJS modules, so we can skip + // this check if we've already seen the module indicator + if (!file.commonJsModuleIndicator && ts.isRequireCall(node)) { + setCommonJsModuleIndicator(node); + } + } function bindClassLikeDeclaration(node) { - if (node.kind === 212 /* ClassDeclaration */) { + if (node.kind === 214 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -4940,7 +5022,7 @@ var ts; // If this is a property-parameter, then also declare the property symbol into the // containing class. if (node.flags & 112 /* AccessibilityModifier */ && - node.parent.kind === 142 /* Constructor */ && + node.parent.kind === 144 /* Constructor */ && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); @@ -4992,7 +5074,8 @@ var ts; increaseIndent: function () { }, decreaseIndent: function () { }, clear: function () { return str = ""; }, - trackSymbol: function () { } + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } }; } return stringWriters.pop(); @@ -5062,7 +5145,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 246 /* SourceFile */) { + while (node && node.kind !== 248 /* SourceFile */) { node = node.parent; } return node; @@ -5174,15 +5257,15 @@ var ts; return current; } switch (current.kind) { - case 246 /* SourceFile */: - case 218 /* CaseBlock */: - case 242 /* CatchClause */: - case 216 /* ModuleDeclaration */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 248 /* SourceFile */: + case 220 /* CaseBlock */: + case 244 /* CatchClause */: + case 218 /* ModuleDeclaration */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: return current; - case 190 /* Block */: + case 192 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -5195,9 +5278,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 209 /* VariableDeclaration */ && + declaration.kind === 211 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 242 /* CatchClause */; + declaration.parent.kind === 244 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -5236,7 +5319,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 246 /* SourceFile */: + case 248 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -5245,16 +5328,16 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 213 /* InterfaceDeclaration */: - case 216 /* ModuleDeclaration */: - case 215 /* EnumDeclaration */: - case 245 /* EnumMember */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 218 /* ModuleDeclaration */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: errorNode = node.name; break; } @@ -5273,16 +5356,20 @@ var ts; return file.externalModuleIndicator !== undefined; } ts.isExternalModule = isExternalModule; + function isExternalOrCommonJsModule(file) { + return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; + } + ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isDeclarationFile(file) { return (file.flags & 8192 /* DeclarationFile */) !== 0; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 215 /* EnumDeclaration */ && isConst(node); + return node.kind === 217 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 161 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 163 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; @@ -5297,14 +5384,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 209 /* VariableDeclaration */) { + if (node.kind === 211 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 210 /* VariableDeclarationList */) { + if (node && node.kind === 212 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 191 /* VariableStatement */) { + if (node && node.kind === 193 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -5319,7 +5406,7 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 193 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; + return node.kind === 195 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -5327,7 +5414,7 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - var commentRanges = (node.kind === 136 /* Parameter */ || node.kind === 135 /* TypeParameter */) ? + var commentRanges = (node.kind === 138 /* Parameter */ || node.kind === 137 /* TypeParameter */) ? ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : getLeadingCommentRangesOfNode(node, sourceFileOfNode); return ts.filter(commentRanges, isJsDocComment); @@ -5342,40 +5429,40 @@ var ts; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (149 /* FirstTypeNode */ <= node.kind && node.kind <= 158 /* LastTypeNode */) { + if (151 /* FirstTypeNode */ <= node.kind && node.kind <= 160 /* LastTypeNode */) { return true; } switch (node.kind) { - case 115 /* AnyKeyword */: - case 126 /* NumberKeyword */: - case 128 /* StringKeyword */: - case 118 /* BooleanKeyword */: - case 129 /* SymbolKeyword */: + case 117 /* AnyKeyword */: + case 128 /* NumberKeyword */: + case 130 /* StringKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: return true; - case 101 /* VoidKeyword */: - return node.parent.kind !== 175 /* VoidExpression */; + case 103 /* VoidKeyword */: + return node.parent.kind !== 177 /* VoidExpression */; case 9 /* StringLiteral */: // Specialized signatures can have string literals as their parameters' type names - return node.parent.kind === 136 /* Parameter */; - case 186 /* ExpressionWithTypeArguments */: + return node.parent.kind === 138 /* Parameter */; + case 188 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 67 /* Identifier */: + case 69 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } - // fall through - case 133 /* QualifiedName */: - case 164 /* PropertyAccessExpression */: // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */ || node.kind === 166 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 135 /* QualifiedName */: + case 166 /* PropertyAccessExpression */: + case 97 /* ThisKeyword */: var parent_1 = node.parent; - if (parent_1.kind === 152 /* TypeQuery */) { + if (parent_1.kind === 154 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -5384,38 +5471,38 @@ var ts; // // Calling isTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (149 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 158 /* LastTypeNode */) { + if (151 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 160 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 135 /* TypeParameter */: + case 137 /* TypeParameter */: return node === parent_1.constraint; - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 136 /* Parameter */: - case 209 /* VariableDeclaration */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 138 /* Parameter */: + case 211 /* VariableDeclaration */: return node === parent_1.type; - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 142 /* Constructor */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 144 /* Constructor */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return node === parent_1.type; - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: return node === parent_1.type; - case 169 /* TypeAssertionExpression */: + case 171 /* TypeAssertionExpression */: return node === parent_1.type; - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 168 /* TaggedTemplateExpression */: + case 170 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -5429,23 +5516,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 202 /* ReturnStatement */: + case 204 /* ReturnStatement */: return visitor(node); - case 218 /* CaseBlock */: - case 190 /* Block */: - case 194 /* IfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 203 /* WithStatement */: - case 204 /* SwitchStatement */: - case 239 /* CaseClause */: - case 240 /* DefaultClause */: - case 205 /* LabeledStatement */: - case 207 /* TryStatement */: - case 242 /* CatchClause */: + case 220 /* CaseBlock */: + case 192 /* Block */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 205 /* WithStatement */: + case 206 /* SwitchStatement */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + case 207 /* LabeledStatement */: + case 209 /* TryStatement */: + case 244 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -5455,18 +5542,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 182 /* YieldExpression */: + case 184 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 215 /* EnumDeclaration */: - case 213 /* InterfaceDeclaration */: - case 216 /* ModuleDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: + case 218 /* ModuleDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. @@ -5474,7 +5561,7 @@ var ts; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 134 /* ComputedPropertyName */) { + if (name_5 && name_5.kind === 136 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(name_5.expression); @@ -5493,14 +5580,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 161 /* BindingElement */: - case 245 /* EnumMember */: - case 136 /* Parameter */: - case 243 /* PropertyAssignment */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 244 /* ShorthandPropertyAssignment */: - case 209 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 247 /* EnumMember */: + case 138 /* Parameter */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 246 /* ShorthandPropertyAssignment */: + case 211 /* VariableDeclaration */: return true; } } @@ -5508,29 +5595,29 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* SetAccessor */); + return node && (node.kind === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */); + return node && (node.kind === 214 /* ClassDeclaration */ || node.kind === 186 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 142 /* Constructor */: - case 171 /* FunctionExpression */: - case 211 /* FunctionDeclaration */: - case 172 /* ArrowFunction */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: - case 150 /* FunctionType */: - case 151 /* ConstructorType */: + case 144 /* Constructor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: return true; } } @@ -5539,24 +5626,24 @@ var ts; ts.isFunctionLike = isFunctionLike; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: return true; } return false; } ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 190 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 192 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 141 /* MethodDeclaration */ && node.parent.kind === 163 /* ObjectLiteralExpression */; + return node && node.kind === 143 /* MethodDeclaration */ && node.parent.kind === 165 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -5584,7 +5671,7 @@ var ts; return undefined; } switch (node.kind) { - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -5599,9 +5686,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 137 /* Decorator */: + case 139 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 136 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 138 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5612,23 +5699,26 @@ var ts; node = node.parent; } break; - case 172 /* ArrowFunction */: + case 174 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 216 /* ModuleDeclaration */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 215 /* EnumDeclaration */: - case 246 /* SourceFile */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 218 /* ModuleDeclaration */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 217 /* EnumDeclaration */: + case 248 /* SourceFile */: return node; } } @@ -5640,7 +5730,7 @@ var ts; if (!node) return node; switch (node.kind) { - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'super' container. // A computed property name in a class needs to be a super container @@ -5655,9 +5745,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 137 /* Decorator */: + case 139 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 136 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 138 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5668,19 +5758,19 @@ var ts; node = node.parent; } break; - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: if (!includeFunctions) { continue; } - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return node; } } @@ -5689,12 +5779,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 149 /* TypeReference */: + case 151 /* TypeReference */: return node.typeName; - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return node.expression; - case 67 /* Identifier */: - case 133 /* QualifiedName */: + case 69 /* Identifier */: + case 135 /* QualifiedName */: return node; } } @@ -5702,7 +5792,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 168 /* TaggedTemplateExpression */) { + if (node.kind === 170 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -5711,44 +5801,44 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: // classes are valid targets return true; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 212 /* ClassDeclaration */; - case 136 /* Parameter */: + return node.parent.kind === 214 /* ClassDeclaration */; + case 138 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; - return node.parent.body && node.parent.parent.kind === 212 /* ClassDeclaration */; - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 141 /* MethodDeclaration */: + return node.parent.body && node.parent.parent.kind === 214 /* ClassDeclaration */; + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 143 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. - return node.body && node.parent.kind === 212 /* ClassDeclaration */; + return node.body && node.parent.kind === 214 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: if (node.decorators) { return true; } return false; - case 139 /* PropertyDeclaration */: - case 136 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 138 /* Parameter */: if (node.decorators) { return true; } return false; - case 143 /* GetAccessor */: + case 145 /* GetAccessor */: if (node.body && node.decorators) { return true; } return false; - case 141 /* MethodDeclaration */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 146 /* SetAccessor */: if (node.body && node.decorators) { return true; } @@ -5759,10 +5849,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 141 /* MethodDeclaration */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 146 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -5772,96 +5862,106 @@ var ts; return nodeIsDecorated(node) || childIsDecorated(node); } ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; + function isPropertyAccessExpression(node) { + return node.kind === 166 /* PropertyAccessExpression */; + } + ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isElementAccessExpression(node) { + return node.kind === 167 /* ElementAccessExpression */; + } + ts.isElementAccessExpression = isElementAccessExpression; function isExpression(node) { switch (node.kind) { - case 95 /* ThisKeyword */: - case 93 /* SuperKeyword */: - case 91 /* NullKeyword */: - case 97 /* TrueKeyword */: - case 82 /* FalseKeyword */: + case 95 /* SuperKeyword */: + case 93 /* NullKeyword */: + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: case 10 /* RegularExpressionLiteral */: - case 162 /* ArrayLiteralExpression */: - case 163 /* ObjectLiteralExpression */: - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 168 /* TaggedTemplateExpression */: - case 187 /* AsExpression */: - case 169 /* TypeAssertionExpression */: - case 170 /* ParenthesizedExpression */: - case 171 /* FunctionExpression */: - case 184 /* ClassExpression */: - case 172 /* ArrowFunction */: - case 175 /* VoidExpression */: - case 173 /* DeleteExpression */: - case 174 /* TypeOfExpression */: - case 177 /* PrefixUnaryExpression */: - case 178 /* PostfixUnaryExpression */: - case 179 /* BinaryExpression */: - case 180 /* ConditionalExpression */: - case 183 /* SpreadElementExpression */: - case 181 /* TemplateExpression */: + case 164 /* ArrayLiteralExpression */: + case 165 /* ObjectLiteralExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 170 /* TaggedTemplateExpression */: + case 189 /* AsExpression */: + case 171 /* TypeAssertionExpression */: + case 172 /* ParenthesizedExpression */: + case 173 /* FunctionExpression */: + case 186 /* ClassExpression */: + case 174 /* ArrowFunction */: + case 177 /* VoidExpression */: + case 175 /* DeleteExpression */: + case 176 /* TypeOfExpression */: + case 179 /* PrefixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: + case 181 /* BinaryExpression */: + case 182 /* ConditionalExpression */: + case 185 /* SpreadElementExpression */: + case 183 /* TemplateExpression */: case 11 /* NoSubstitutionTemplateLiteral */: - case 185 /* OmittedExpression */: - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - case 182 /* YieldExpression */: + case 187 /* OmittedExpression */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 184 /* YieldExpression */: + case 178 /* AwaitExpression */: return true; - case 133 /* QualifiedName */: - while (node.parent.kind === 133 /* QualifiedName */) { + case 135 /* QualifiedName */: + while (node.parent.kind === 135 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 152 /* TypeQuery */; - case 67 /* Identifier */: - if (node.parent.kind === 152 /* TypeQuery */) { + return node.parent.kind === 154 /* TypeQuery */; + case 69 /* Identifier */: + if (node.parent.kind === 154 /* TypeQuery */) { return true; } // fall through case 8 /* NumericLiteral */: case 9 /* StringLiteral */: + case 97 /* ThisKeyword */: var parent_2 = node.parent; switch (parent_2.kind) { - case 209 /* VariableDeclaration */: - case 136 /* Parameter */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 245 /* EnumMember */: - case 243 /* PropertyAssignment */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 247 /* EnumMember */: + case 245 /* PropertyAssignment */: + case 163 /* BindingElement */: return parent_2.initializer === node; - case 193 /* ExpressionStatement */: - case 194 /* IfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 202 /* ReturnStatement */: - case 203 /* WithStatement */: - case 204 /* SwitchStatement */: - case 239 /* CaseClause */: - case 206 /* ThrowStatement */: - case 204 /* SwitchStatement */: + case 195 /* ExpressionStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 204 /* ReturnStatement */: + case 205 /* WithStatement */: + case 206 /* SwitchStatement */: + case 241 /* CaseClause */: + case 208 /* ThrowStatement */: + case 206 /* SwitchStatement */: return parent_2.expression === node; - case 197 /* ForStatement */: + case 199 /* ForStatement */: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 210 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 212 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 212 /* VariableDeclarationList */) || forInStatement.expression === node; - case 169 /* TypeAssertionExpression */: - case 187 /* AsExpression */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: return node === parent_2.expression; - case 188 /* TemplateSpan */: + case 190 /* TemplateSpan */: return node === parent_2.expression; - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: return node === parent_2.expression; - case 137 /* Decorator */: - case 238 /* JsxExpression */: + case 139 /* Decorator */: + case 240 /* JsxExpression */: + case 239 /* JsxSpreadAttribute */: return true; - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -5872,6 +5972,12 @@ var ts; return false; } ts.isExpression = isExpression; + function isExternalModuleNameRelative(moduleName) { + // TypeScript 1.0 spec (April 2014): 11.2.1 + // An external module name is "relative" if the first term is "." or "..". + return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); return moduleState === 1 /* Instantiated */ || @@ -5879,7 +5985,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */; + return node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 232 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5888,20 +5994,70 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 230 /* ExternalModuleReference */; + return node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 232 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; + function isSourceFileJavaScript(file) { + return isInJavaScriptFile(file); + } + ts.isSourceFileJavaScript = isSourceFileJavaScript; + function isInJavaScriptFile(node) { + return node && !!(node.parserContextFlags & 32 /* JavaScriptFile */); + } + ts.isInJavaScriptFile = isInJavaScriptFile; + /** + * Returns true if the node is a CallExpression to the identifier 'require' with + * exactly one argument. + * This function does not test if the node is in a JavaScript file or not. + */ + function isRequireCall(expression) { + // of the form 'require("name")' + return expression.kind === 168 /* CallExpression */ && + expression.expression.kind === 69 /* Identifier */ && + expression.expression.text === "require" && + expression.arguments.length === 1; + } + ts.isRequireCall = isRequireCall; + /** + * Returns true if the node is an assignment to a property on the identifier 'exports'. + * This function does not test if the node is in a JavaScript file or not. + */ + function isExportsPropertyAssignment(expression) { + // of the form 'exports.name = expr' where 'name' and 'expr' are arbitrary + return isInJavaScriptFile(expression) && + (expression.kind === 181 /* BinaryExpression */) && + (expression.operatorToken.kind === 56 /* EqualsToken */) && + (expression.left.kind === 166 /* PropertyAccessExpression */) && + (expression.left.expression.kind === 69 /* Identifier */) && + ((expression.left.expression).text === "exports"); + } + ts.isExportsPropertyAssignment = isExportsPropertyAssignment; + /** + * Returns true if the node is an assignment to the property access expression 'module.exports'. + * This function does not test if the node is in a JavaScript file or not. + */ + function isModuleExportsAssignment(expression) { + // of the form 'module.exports = expr' where 'expr' is arbitrary + return isInJavaScriptFile(expression) && + (expression.kind === 181 /* BinaryExpression */) && + (expression.operatorToken.kind === 56 /* EqualsToken */) && + (expression.left.kind === 166 /* PropertyAccessExpression */) && + (expression.left.expression.kind === 69 /* Identifier */) && + ((expression.left.expression).text === "module") && + (expression.left.name.text === "exports"); + } + ts.isModuleExportsAssignment = isModuleExportsAssignment; function getExternalModuleName(node) { - if (node.kind === 220 /* ImportDeclaration */) { + if (node.kind === 222 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 219 /* ImportEqualsDeclaration */) { + if (node.kind === 221 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 230 /* ExternalModuleReference */) { + if (reference.kind === 232 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 226 /* ExportDeclaration */) { + if (node.kind === 228 /* ExportDeclaration */) { return node.moduleSpecifier; } } @@ -5909,13 +6065,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 136 /* Parameter */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 244 /* ShorthandPropertyAssignment */: - case 243 /* PropertyAssignment */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 138 /* Parameter */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 246 /* ShorthandPropertyAssignment */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -5923,9 +6079,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 259 /* JSDocFunctionType */ && + return node.kind === 261 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 261 /* JSDocConstructorType */; + node.parameters[0].type.kind === 263 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -5939,26 +6095,26 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 267 /* JSDocTypeTag */); + return getJSDocTag(node, 269 /* JSDocTypeTag */); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 266 /* JSDocReturnTag */); + return getJSDocTag(node, 268 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 268 /* JSDocTemplateTag */); + return getJSDocTag(node, 270 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 67 /* Identifier */) { + if (parameter.name && parameter.name.kind === 69 /* Identifier */) { // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 265 /* JSDocParameterTag */) { + if (t.kind === 267 /* JSDocParameterTag */) { var parameterTag = t; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { @@ -5977,12 +6133,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32 /* JavaScriptFile */) { - if (node.type && node.type.kind === 260 /* JSDocVariadicType */) { + if (node.type && node.type.kind === 262 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 260 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 262 /* JSDocVariadicType */; } } return node.dotDotDotToken !== undefined; @@ -6003,7 +6159,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 160 /* ArrayBindingPattern */ || node.kind === 159 /* ObjectBindingPattern */); + return !!node && (node.kind === 162 /* ArrayBindingPattern */ || node.kind === 161 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -6018,34 +6174,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 172 /* ArrowFunction */: - case 161 /* BindingElement */: - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 142 /* Constructor */: - case 215 /* EnumDeclaration */: - case 245 /* EnumMember */: - case 228 /* ExportSpecifier */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 143 /* GetAccessor */: - case 221 /* ImportClause */: - case 219 /* ImportEqualsDeclaration */: - case 224 /* ImportSpecifier */: - case 213 /* InterfaceDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 216 /* ModuleDeclaration */: - case 222 /* NamespaceImport */: - case 136 /* Parameter */: - case 243 /* PropertyAssignment */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 144 /* SetAccessor */: - case 244 /* ShorthandPropertyAssignment */: - case 214 /* TypeAliasDeclaration */: - case 135 /* TypeParameter */: - case 209 /* VariableDeclaration */: + case 174 /* ArrowFunction */: + case 163 /* BindingElement */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 144 /* Constructor */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 230 /* ExportSpecifier */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 145 /* GetAccessor */: + case 223 /* ImportClause */: + case 221 /* ImportEqualsDeclaration */: + case 226 /* ImportSpecifier */: + case 215 /* InterfaceDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 218 /* ModuleDeclaration */: + case 224 /* NamespaceImport */: + case 138 /* Parameter */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 146 /* SetAccessor */: + case 246 /* ShorthandPropertyAssignment */: + case 216 /* TypeAliasDeclaration */: + case 137 /* TypeParameter */: + case 211 /* VariableDeclaration */: return true; } return false; @@ -6053,25 +6209,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 201 /* BreakStatement */: - case 200 /* ContinueStatement */: - case 208 /* DebuggerStatement */: - case 195 /* DoStatement */: - case 193 /* ExpressionStatement */: - case 192 /* EmptyStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 197 /* ForStatement */: - case 194 /* IfStatement */: - case 205 /* LabeledStatement */: - case 202 /* ReturnStatement */: - case 204 /* SwitchStatement */: - case 96 /* ThrowKeyword */: - case 207 /* TryStatement */: - case 191 /* VariableStatement */: - case 196 /* WhileStatement */: - case 203 /* WithStatement */: - case 225 /* ExportAssignment */: + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 210 /* DebuggerStatement */: + case 197 /* DoStatement */: + case 195 /* ExpressionStatement */: + case 194 /* EmptyStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 199 /* ForStatement */: + case 196 /* IfStatement */: + case 207 /* LabeledStatement */: + case 204 /* ReturnStatement */: + case 206 /* SwitchStatement */: + case 98 /* ThrowKeyword */: + case 209 /* TryStatement */: + case 193 /* VariableStatement */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 227 /* ExportAssignment */: return true; default: return false; @@ -6080,13 +6236,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 142 /* Constructor */: - case 139 /* PropertyDeclaration */: - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 140 /* MethodSignature */: - case 147 /* IndexSignature */: + case 144 /* Constructor */: + case 141 /* PropertyDeclaration */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 142 /* MethodSignature */: + case 149 /* IndexSignature */: return true; default: return false; @@ -6095,11 +6251,11 @@ var ts; ts.isClassElement = isClassElement; // True if the given identifier, string literal, or number literal is the name of a declaration node function isDeclarationName(name) { - if (name.kind !== 67 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { + if (name.kind !== 69 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { return false; } var parent = name.parent; - if (parent.kind === 224 /* ImportSpecifier */ || parent.kind === 228 /* ExportSpecifier */) { + if (parent.kind === 226 /* ImportSpecifier */ || parent.kind === 230 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -6114,31 +6270,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 245 /* EnumMember */: - case 243 /* PropertyAssignment */: - case 164 /* PropertyAccessExpression */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 247 /* EnumMember */: + case 245 /* PropertyAssignment */: + case 166 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 133 /* QualifiedName */: + case 135 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 133 /* QualifiedName */) { + while (parent.kind === 135 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 152 /* TypeQuery */; + return parent.kind === 154 /* TypeQuery */; } return false; - case 161 /* BindingElement */: - case 224 /* ImportSpecifier */: + case 163 /* BindingElement */: + case 226 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 228 /* ExportSpecifier */: + case 230 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -6154,26 +6310,26 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 219 /* ImportEqualsDeclaration */ || - node.kind === 221 /* ImportClause */ && !!node.name || - node.kind === 222 /* NamespaceImport */ || - node.kind === 224 /* ImportSpecifier */ || - node.kind === 228 /* ExportSpecifier */ || - node.kind === 225 /* ExportAssignment */ && node.expression.kind === 67 /* Identifier */; + return node.kind === 221 /* ImportEqualsDeclaration */ || + node.kind === 223 /* ImportClause */ && !!node.name || + node.kind === 224 /* NamespaceImport */ || + node.kind === 226 /* ImportSpecifier */ || + node.kind === 230 /* ExportSpecifier */ || + node.kind === 227 /* ExportAssignment */ && node.expression.kind === 69 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 104 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 106 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -6242,7 +6398,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 68 /* FirstKeyword */ <= token && token <= 132 /* LastKeyword */; + return 70 /* FirstKeyword */ <= token && token <= 134 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -6262,7 +6418,7 @@ var ts; */ function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 134 /* ComputedPropertyName */ && + declaration.name.kind === 136 /* ComputedPropertyName */ && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; @@ -6272,14 +6428,14 @@ var ts; * where Symbol is literally the word "Symbol", and name is any identifierName */ function isWellKnownSymbolSyntactically(node) { - return node.kind === 164 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); + return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 67 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { + if (name.kind === 69 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { return name.text; } - if (name.kind === 134 /* ComputedPropertyName */) { + if (name.kind === 136 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -6297,21 +6453,21 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 67 /* Identifier */ && node.text === "Symbol"; + return node.kind === 69 /* Identifier */ && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 113 /* AbstractKeyword */: - case 116 /* AsyncKeyword */: - case 72 /* ConstKeyword */: - case 120 /* DeclareKeyword */: - case 75 /* DefaultKeyword */: - case 80 /* ExportKeyword */: - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 111 /* StaticKeyword */: + case 115 /* AbstractKeyword */: + case 118 /* AsyncKeyword */: + case 74 /* ConstKeyword */: + case 122 /* DeclareKeyword */: + case 77 /* DefaultKeyword */: + case 82 /* ExportKeyword */: + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 113 /* StaticKeyword */: return true; } return false; @@ -6319,28 +6475,28 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 136 /* Parameter */; + return root.kind === 138 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 161 /* BindingElement */) { + while (node.kind === 163 /* BindingElement */) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 216 /* ModuleDeclaration */ || n.kind === 246 /* SourceFile */; + return isFunctionLike(n) || n.kind === 218 /* ModuleDeclaration */ || n.kind === 248 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function cloneEntityName(node) { - if (node.kind === 67 /* Identifier */) { - var clone_1 = createSynthesizedNode(67 /* Identifier */); + if (node.kind === 69 /* Identifier */) { + var clone_1 = createSynthesizedNode(69 /* Identifier */); clone_1.text = node.text; return clone_1; } else { - var clone_2 = createSynthesizedNode(133 /* QualifiedName */); + var clone_2 = createSynthesizedNode(135 /* QualifiedName */); clone_2.left = cloneEntityName(node.left); clone_2.left.parent = clone_2; clone_2.right = cloneEntityName(node.right); @@ -6595,7 +6751,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 142 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 144 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -6624,10 +6780,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 143 /* GetAccessor */) { + if (accessor.kind === 145 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 144 /* SetAccessor */) { + else if (accessor.kind === 146 /* SetAccessor */) { setAccessor = accessor; } else { @@ -6636,7 +6792,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */) + if ((member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -6647,10 +6803,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 143 /* GetAccessor */ && !getAccessor) { + if (member.kind === 145 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 144 /* SetAccessor */ && !setAccessor) { + if (member.kind === 146 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6783,16 +6939,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 111 /* StaticKeyword */: return 128 /* Static */; - case 110 /* PublicKeyword */: return 16 /* Public */; - case 109 /* ProtectedKeyword */: return 64 /* Protected */; - case 108 /* PrivateKeyword */: return 32 /* Private */; - case 113 /* AbstractKeyword */: return 256 /* Abstract */; - case 80 /* ExportKeyword */: return 1 /* Export */; - case 120 /* DeclareKeyword */: return 2 /* Ambient */; - case 72 /* ConstKeyword */: return 32768 /* Const */; - case 75 /* DefaultKeyword */: return 1024 /* Default */; - case 116 /* AsyncKeyword */: return 512 /* Async */; + case 113 /* StaticKeyword */: return 128 /* Static */; + case 112 /* PublicKeyword */: return 16 /* Public */; + case 111 /* ProtectedKeyword */: return 64 /* Protected */; + case 110 /* PrivateKeyword */: return 32 /* Private */; + case 115 /* AbstractKeyword */: return 256 /* Abstract */; + case 82 /* ExportKeyword */: return 1 /* Export */; + case 122 /* DeclareKeyword */: return 2 /* Ambient */; + case 74 /* ConstKeyword */: return 32768 /* Const */; + case 77 /* DefaultKeyword */: return 1024 /* Default */; + case 118 /* AsyncKeyword */: return 512 /* Async */; } return 0; } @@ -6800,29 +6956,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: - case 167 /* NewExpression */: - case 166 /* CallExpression */: - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - case 168 /* TaggedTemplateExpression */: - case 162 /* ArrayLiteralExpression */: - case 170 /* ParenthesizedExpression */: - case 163 /* ObjectLiteralExpression */: - case 184 /* ClassExpression */: - case 171 /* FunctionExpression */: - case 67 /* Identifier */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 169 /* NewExpression */: + case 168 /* CallExpression */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 170 /* TaggedTemplateExpression */: + case 164 /* ArrayLiteralExpression */: + case 172 /* ParenthesizedExpression */: + case 165 /* ObjectLiteralExpression */: + case 186 /* ClassExpression */: + case 173 /* FunctionExpression */: + case 69 /* Identifier */: case 10 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 11 /* NoSubstitutionTemplateLiteral */: - case 181 /* TemplateExpression */: - case 82 /* FalseKeyword */: - case 91 /* NullKeyword */: - case 95 /* ThisKeyword */: - case 97 /* TrueKeyword */: - case 93 /* SuperKeyword */: + case 183 /* TemplateExpression */: + case 84 /* FalseKeyword */: + case 93 /* NullKeyword */: + case 97 /* ThisKeyword */: + case 99 /* TrueKeyword */: + case 95 /* SuperKeyword */: return true; } } @@ -6830,12 +6986,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 55 /* FirstAssignment */ && token <= 66 /* LastAssignment */; + return token >= 56 /* FirstAssignment */ && token <= 68 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 186 /* ExpressionWithTypeArguments */ && - node.parent.token === 81 /* ExtendsKeyword */ && + return node.kind === 188 /* ExpressionWithTypeArguments */ && + node.parent.token === 83 /* ExtendsKeyword */ && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -6846,10 +7002,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 67 /* Identifier */) { + if (node.kind === 69 /* Identifier */) { return true; } - else if (node.kind === 164 /* PropertyAccessExpression */) { + else if (isPropertyAccessExpression(node)) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -6857,16 +7013,16 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 163 /* ObjectLiteralExpression */) { + if (kind === 165 /* ObjectLiteralExpression */) { return expression.properties.length === 0; } - if (kind === 162 /* ArrayLiteralExpression */) { + if (kind === 164 /* ArrayLiteralExpression */) { return expression.elements.length === 0; } return false; @@ -6876,12 +7032,12 @@ var ts; return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function isJavaScript(fileName) { - return ts.fileExtensionIs(fileName, ".js"); + function hasJavaScriptFileExtension(fileName) { + return ts.fileExtensionIs(fileName, ".js") || ts.fileExtensionIs(fileName, ".jsx"); } - ts.isJavaScript = isJavaScript; + ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; function isTsx(fileName) { - return ts.fileExtensionIs(fileName, ".tsx"); + return ts.fileExtensionIs(fileName, ".tsx") || ts.fileExtensionIs(fileName, ".jsx"); } ts.isTsx = isTsx; /** @@ -7178,9 +7334,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 135 /* TypeParameter */) { + if (d && d.kind === 137 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 215 /* InterfaceDeclaration */) { return current; } } @@ -7192,7 +7348,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(270 /* Count */); + var nodeConstructors = new Array(272 /* Count */); /* @internal */ ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -7237,20 +7393,26 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 133 /* QualifiedName */: + case 135 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 135 /* TypeParameter */: + case 137 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 136 /* Parameter */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 243 /* PropertyAssignment */: - case 244 /* ShorthandPropertyAssignment */: - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: + case 246 /* ShorthandPropertyAssignment */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.equalsToken) || + visitNode(cbNode, node.objectAssignmentInitializer); + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 245 /* PropertyAssignment */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -7259,24 +7421,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 171 /* FunctionExpression */: - case 211 /* FunctionDeclaration */: - case 172 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -7287,290 +7449,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 149 /* TypeReference */: + case 151 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 148 /* TypePredicate */: + case 150 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 153 /* TypeLiteral */: + case 155 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 154 /* ArrayType */: + case 156 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 155 /* TupleType */: + case 157 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 156 /* UnionType */: - case 157 /* IntersectionType */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 158 /* ParenthesizedType */: + case 160 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 159 /* ObjectBindingPattern */: - case 160 /* ArrayBindingPattern */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 164 /* PropertyAccessExpression */: + case 166 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 165 /* ElementAccessExpression */: + case 167 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 168 /* TaggedTemplateExpression */: + case 170 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 169 /* TypeAssertionExpression */: + case 171 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 173 /* DeleteExpression */: + case 175 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 174 /* TypeOfExpression */: + case 176 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 175 /* VoidExpression */: + case 177 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 182 /* YieldExpression */: + case 184 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 176 /* AwaitExpression */: + case 178 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 178 /* PostfixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 187 /* AsExpression */: + case 189 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 183 /* SpreadElementExpression */: + case 185 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 190 /* Block */: - case 217 /* ModuleBlock */: + case 192 /* Block */: + case 219 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 246 /* SourceFile */: + case 248 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 210 /* VariableDeclarationList */: + case 212 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 193 /* ExpressionStatement */: + case 195 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 194 /* IfStatement */: + case 196 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 195 /* DoStatement */: + case 197 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 196 /* WhileStatement */: + case 198 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 197 /* ForStatement */: + case 199 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 198 /* ForInStatement */: + case 200 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 199 /* ForOfStatement */: + case 201 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 200 /* ContinueStatement */: - case 201 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: return visitNode(cbNode, node.label); - case 202 /* ReturnStatement */: + case 204 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 203 /* WithStatement */: + case 205 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 204 /* SwitchStatement */: + case 206 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 218 /* CaseBlock */: + case 220 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 239 /* CaseClause */: + case 241 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 240 /* DefaultClause */: + case 242 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 206 /* ThrowStatement */: + case 208 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 207 /* TryStatement */: + case 209 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 137 /* Decorator */: + case 139 /* Decorator */: return visitNode(cbNode, node.expression); - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: 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 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: 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 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 245 /* EnumMember */: + case 247 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 221 /* ImportClause */: + case 223 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 222 /* NamespaceImport */: + case 224 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 223 /* NamedImports */: - case 227 /* NamedExports */: + case 225 /* NamedImports */: + case 229 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 224 /* ImportSpecifier */: - case 228 /* ExportSpecifier */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 181 /* TemplateExpression */: + case 183 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 188 /* TemplateSpan */: + case 190 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 241 /* HeritageClause */: + case 243 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 230 /* ExternalModuleReference */: + case 232 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 229 /* MissingDeclaration */: + case 231 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 231 /* JsxElement */: + case 233 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 232 /* JsxSelfClosingElement */: - case 233 /* JsxOpeningElement */: + case 234 /* JsxSelfClosingElement */: + case 235 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 236 /* JsxAttribute */: + case 238 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 237 /* JsxSpreadAttribute */: + case 239 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 238 /* JsxExpression */: + case 240 /* JsxExpression */: return visitNode(cbNode, node.expression); - case 235 /* JsxClosingElement */: + case 237 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 247 /* JSDocTypeExpression */: + case 249 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 251 /* JSDocUnionType */: + case 253 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 252 /* JSDocTupleType */: + case 254 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 250 /* JSDocArrayType */: + case 252 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 254 /* JSDocNonNullableType */: + case 256 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 253 /* JSDocNullableType */: + case 255 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 255 /* JSDocRecordType */: + case 257 /* JSDocRecordType */: return visitNodes(cbNodes, node.members); - case 257 /* JSDocTypeReference */: + case 259 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 258 /* JSDocOptionalType */: + case 260 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 259 /* JSDocFunctionType */: + case 261 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 260 /* JSDocVariadicType */: + case 262 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 261 /* JSDocConstructorType */: + case 263 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 262 /* JSDocThisType */: + case 264 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 256 /* JSDocRecordMember */: + case 258 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 263 /* JSDocComment */: + case 265 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 265 /* JSDocParameterTag */: + case 267 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 266 /* JSDocReturnTag */: + case 268 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 267 /* JSDocTypeTag */: + case 269 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 268 /* JSDocTemplateTag */: + case 270 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); } } @@ -7701,13 +7863,14 @@ var ts; // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes) { - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); + var isJavaScriptFile = ts.hasJavaScriptFileExtension(fileName) || _sourceText.lastIndexOf("// @language=javascript", 0) === 0; + initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor); var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); clearState(); return result; } Parser.parseSourceFile = parseSourceFile; - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor) { + function initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor) { sourceText = _sourceText; syntaxCursor = _syntaxCursor; parseDiagnostics = []; @@ -7715,7 +7878,7 @@ var ts; identifiers = {}; identifierCount = 0; nodeCount = 0; - contextFlags = ts.isJavaScript(fileName) ? 32 /* JavaScriptFile */ : 0 /* None */; + contextFlags = isJavaScriptFile ? 32 /* JavaScriptFile */ : 0 /* None */; parseErrorBeforeNextFinishedNode = false; // Initialize and prime the scanner before parsing the source elements. scanner.setText(sourceText); @@ -7736,6 +7899,9 @@ var ts; } function parseSourceFileWorker(fileName, languageVersion, setParentNodes) { sourceFile = createSourceFile(fileName, languageVersion); + if (contextFlags & 32 /* JavaScriptFile */) { + sourceFile.parserContextFlags = 32 /* JavaScriptFile */; + } // Prime the scanner. token = nextToken(); processReferenceComments(sourceFile); @@ -7753,7 +7919,7 @@ var ts; // If this is a javascript file, proactively see if we can get JSDoc comments for // relevant nodes in the file. We'll use these to provide typing informaion if they're // available. - if (ts.isJavaScript(fileName)) { + if (ts.isSourceFileJavaScript(sourceFile)) { addJSDocComments(); } return sourceFile; @@ -7765,9 +7931,9 @@ var ts; // Add additional cases as necessary depending on how we see JSDoc comments used // in the wild. switch (node.kind) { - case 191 /* VariableStatement */: - case 211 /* FunctionDeclaration */: - case 136 /* Parameter */: + case 193 /* VariableStatement */: + case 213 /* FunctionDeclaration */: + case 138 /* Parameter */: addJSDocComment(node); } forEachChild(node, visit); @@ -7808,7 +7974,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(246 /* SourceFile */, /*pos*/ 0); + var sourceFile = createNode(248 /* SourceFile */, /*pos*/ 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -7972,7 +8138,7 @@ var ts; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; // Note: it is not actually necessary to save/restore the context flags here. That's - // because the saving/restorating of these flags happens naturally through the recursive + // because the saving/restoring of these flags happens naturally through the recursive // descent nature of our parser. However, we still store this here just so we can // assert that that invariant holds. var saveContextFlags = contextFlags; @@ -8007,20 +8173,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token === 67 /* Identifier */) { + if (token === 69 /* Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token === 112 /* YieldKeyword */ && inYieldContext()) { + if (token === 114 /* YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token === 117 /* AwaitKeyword */ && inAwaitContext()) { + if (token === 119 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token > 103 /* LastReservedWord */; + return token > 105 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -8126,16 +8292,16 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(67 /* Identifier */); + var node = createNode(69 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token !== 67 /* Identifier */) { + if (token !== 69 /* Identifier */) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -8170,7 +8336,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(134 /* ComputedPropertyName */); + var node = createNode(136 /* ComputedPropertyName */); parseExpected(19 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -8183,21 +8349,28 @@ var ts; return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 72 /* ConstKeyword */) { + if (token === 74 /* ConstKeyword */) { // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 79 /* EnumKeyword */; + return nextToken() === 81 /* EnumKeyword */; } - if (token === 80 /* ExportKeyword */) { + if (token === 82 /* ExportKeyword */) { nextToken(); - if (token === 75 /* DefaultKeyword */) { + if (token === 77 /* DefaultKeyword */) { return lookAhead(nextTokenIsClassOrFunction); } return token !== 37 /* AsteriskToken */ && token !== 15 /* OpenBraceToken */ && canFollowModifier(); } - if (token === 75 /* DefaultKeyword */) { + if (token === 77 /* DefaultKeyword */) { return nextTokenIsClassOrFunction(); } + if (token === 113 /* StaticKeyword */) { + nextToken(); + return canFollowModifier(); + } nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return false; + } return canFollowModifier(); } function parseAnyContextualModifier() { @@ -8211,7 +8384,7 @@ var ts; } function nextTokenIsClassOrFunction() { nextToken(); - return token === 71 /* ClassKeyword */ || token === 85 /* FunctionKeyword */; + return token === 73 /* ClassKeyword */ || token === 87 /* FunctionKeyword */; } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -8231,7 +8404,7 @@ var ts; // outer module. We just want to consume and move on. return !(token === 23 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */; + return token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */; case 4 /* TypeMembers */: return isStartOfTypeMember(); case 5 /* ClassMembers */: @@ -8305,7 +8478,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 81 /* ExtendsKeyword */ || next === 104 /* ImplementsKeyword */; + return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 83 /* ExtendsKeyword */ || next === 106 /* ImplementsKeyword */; } return true; } @@ -8318,8 +8491,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 104 /* ImplementsKeyword */ || - token === 81 /* ExtendsKeyword */) { + if (token === 106 /* ImplementsKeyword */ || + token === 83 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -8345,14 +8518,14 @@ var ts; case 21 /* ImportOrExportSpecifiers */: return token === 16 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token === 16 /* CloseBraceToken */ || token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */; + return token === 16 /* CloseBraceToken */ || token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token === 15 /* OpenBraceToken */ || token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; + return token === 15 /* OpenBraceToken */ || token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 17 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */ || token === 15 /* OpenBraceToken */ || token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; + return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */ || token === 15 /* OpenBraceToken */ || token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token === 18 /* CloseParenToken */ || token === 23 /* SemicolonToken */; @@ -8369,11 +8542,11 @@ var ts; case 20 /* HeritageClauses */: return token === 15 /* OpenBraceToken */ || token === 16 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token === 27 /* GreaterThanToken */ || token === 38 /* SlashToken */; + return token === 27 /* GreaterThanToken */ || token === 39 /* SlashToken */; case 14 /* JsxChildren */: return token === 25 /* LessThanToken */ && lookAhead(nextTokenIsSlash); case 22 /* JSDocFunctionParameters */: - return token === 18 /* CloseParenToken */ || token === 53 /* ColonToken */ || token === 16 /* CloseBraceToken */; + return token === 18 /* CloseParenToken */ || token === 54 /* ColonToken */ || token === 16 /* CloseBraceToken */; case 23 /* JSDocTypeArguments */: return token === 27 /* GreaterThanToken */ || token === 16 /* CloseBraceToken */; case 25 /* JSDocTupleTypes */: @@ -8561,20 +8734,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 142 /* Constructor */: - case 147 /* IndexSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 139 /* PropertyDeclaration */: - case 189 /* SemicolonClassElement */: + case 144 /* Constructor */: + case 149 /* IndexSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 191 /* SemicolonClassElement */: return true; - case 141 /* MethodDeclaration */: + case 143 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 67 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 119 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 69 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 121 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -8583,8 +8756,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 239 /* CaseClause */: - case 240 /* DefaultClause */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: return true; } } @@ -8593,58 +8766,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 211 /* FunctionDeclaration */: - case 191 /* VariableStatement */: - case 190 /* Block */: - case 194 /* IfStatement */: - case 193 /* ExpressionStatement */: - case 206 /* ThrowStatement */: - case 202 /* ReturnStatement */: - case 204 /* SwitchStatement */: - case 201 /* BreakStatement */: - case 200 /* ContinueStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 197 /* ForStatement */: - case 196 /* WhileStatement */: - case 203 /* WithStatement */: - case 192 /* EmptyStatement */: - case 207 /* TryStatement */: - case 205 /* LabeledStatement */: - case 195 /* DoStatement */: - case 208 /* DebuggerStatement */: - case 220 /* ImportDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 226 /* ExportDeclaration */: - case 225 /* ExportAssignment */: - case 216 /* ModuleDeclaration */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 214 /* TypeAliasDeclaration */: + case 213 /* FunctionDeclaration */: + case 193 /* VariableStatement */: + case 192 /* Block */: + case 196 /* IfStatement */: + case 195 /* ExpressionStatement */: + case 208 /* ThrowStatement */: + case 204 /* ReturnStatement */: + case 206 /* SwitchStatement */: + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 199 /* ForStatement */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 194 /* EmptyStatement */: + case 209 /* TryStatement */: + case 207 /* LabeledStatement */: + case 197 /* DoStatement */: + case 210 /* DebuggerStatement */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 228 /* ExportDeclaration */: + case 227 /* ExportAssignment */: + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 216 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 245 /* EnumMember */; + return node.kind === 247 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 146 /* ConstructSignature */: - case 140 /* MethodSignature */: - case 147 /* IndexSignature */: - case 138 /* PropertySignature */: - case 145 /* CallSignature */: + case 148 /* ConstructSignature */: + case 142 /* MethodSignature */: + case 149 /* IndexSignature */: + case 140 /* PropertySignature */: + case 147 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 209 /* VariableDeclaration */) { + if (node.kind !== 211 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -8665,7 +8838,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 136 /* Parameter */) { + if (node.kind !== 138 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -8782,7 +8955,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(21 /* DotToken */)) { - var node = createNode(133 /* QualifiedName */, entity.pos); + var node = createNode(135 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -8815,13 +8988,13 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(67 /* Identifier */, /*reportAtCurrentToken*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(69 /* Identifier */, /*reportAtCurrentToken*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(181 /* TemplateExpression */); + var template = createNode(183 /* TemplateExpression */); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; @@ -8834,7 +9007,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(188 /* TemplateSpan */); + var span = createNode(190 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token === 16 /* CloseBraceToken */) { @@ -8876,14 +9049,14 @@ var ts; // TYPES function parseTypeReferenceOrTypePredicate() { var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - if (typeName.kind === 67 /* Identifier */ && token === 122 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (typeName.kind === 69 /* Identifier */ && token === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(148 /* TypePredicate */, typeName.pos); + var node_1 = createNode(150 /* TypePredicate */, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(149 /* TypeReference */, typeName.pos); + var node = createNode(151 /* TypeReference */, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 25 /* LessThanToken */) { node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); @@ -8891,15 +9064,15 @@ var ts; return finishNode(node); } function parseTypeQuery() { - var node = createNode(152 /* TypeQuery */); - parseExpected(99 /* TypeOfKeyword */); + var node = createNode(154 /* TypeQuery */); + parseExpected(101 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(135 /* TypeParameter */); + var node = createNode(137 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(81 /* ExtendsKeyword */)) { + if (parseOptional(83 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -8926,7 +9099,7 @@ var ts; } } function parseParameterType() { - if (parseOptional(53 /* ColonToken */)) { + if (parseOptional(54 /* ColonToken */)) { return token === 9 /* StringLiteral */ ? parseLiteralNode(/*internName*/ true) : parseType(); @@ -8934,7 +9107,7 @@ var ts; return undefined; } function isStartOfParameter() { - return token === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 54 /* AtToken */; + return token === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 55 /* AtToken */; } function setModifiers(node, modifiers) { if (modifiers) { @@ -8943,7 +9116,7 @@ var ts; } } function parseParameter() { - var node = createNode(136 /* Parameter */); + var node = createNode(138 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); @@ -8961,7 +9134,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(52 /* QuestionToken */); + node.questionToken = parseOptionalToken(53 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(/*inParameter*/ true); // Do not check for initializers in an ambient context for parameters. This is not @@ -9037,10 +9210,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 146 /* ConstructSignature */) { - parseExpected(90 /* NewKeyword */); + if (kind === 148 /* ConstructSignature */) { + parseExpected(92 /* NewKeyword */); } - fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -9087,21 +9260,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token === 53 /* ColonToken */ || token === 24 /* CommaToken */) { + if (token === 54 /* ColonToken */ || token === 24 /* CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token !== 52 /* QuestionToken */) { + if (token !== 53 /* QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token === 53 /* ColonToken */ || token === 24 /* CommaToken */ || token === 20 /* CloseBracketToken */; + return token === 54 /* ColonToken */ || token === 24 /* CommaToken */ || token === 20 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(147 /* IndexSignature */, fullStart); + var node = createNode(149 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); @@ -9112,19 +9285,19 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(52 /* QuestionToken */); + var questionToken = parseOptionalToken(53 /* QuestionToken */); if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { - var method = createNode(140 /* MethodSignature */, fullStart); + var method = createNode(142 /* MethodSignature */, fullStart); method.name = name; method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(138 /* PropertySignature */, fullStart); + var property = createNode(140 /* PropertySignature */, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -9158,23 +9331,23 @@ var ts; nextToken(); return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */ || - token === 52 /* QuestionToken */ || - token === 53 /* ColonToken */ || + token === 53 /* QuestionToken */ || + token === 54 /* ColonToken */ || canParseSemicolon(); } function parseTypeMember() { switch (token) { case 17 /* OpenParenToken */: case 25 /* LessThanToken */: - return parseSignatureMember(145 /* CallSignature */); + return parseSignatureMember(147 /* CallSignature */); case 19 /* OpenBracketToken */: // Indexer or computed property return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined) : parsePropertyOrMethodSignature(); - case 90 /* NewKeyword */: + case 92 /* NewKeyword */: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(146 /* ConstructSignature */); + return parseSignatureMember(148 /* ConstructSignature */); } // fall through. case 9 /* StringLiteral */: @@ -9211,7 +9384,7 @@ var ts; return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(153 /* TypeLiteral */); + var node = createNode(155 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -9227,12 +9400,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(155 /* TupleType */); + var node = createNode(157 /* TupleType */); node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(158 /* ParenthesizedType */); + var node = createNode(160 /* ParenthesizedType */); parseExpected(17 /* OpenParenToken */); node.type = parseType(); parseExpected(18 /* CloseParenToken */); @@ -9240,8 +9413,8 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 151 /* ConstructorType */) { - parseExpected(90 /* NewKeyword */); + if (kind === 153 /* ConstructorType */) { + parseExpected(92 /* NewKeyword */); } fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); return finishNode(node); @@ -9252,17 +9425,18 @@ var ts; } function parseNonArrayType() { switch (token) { - case 115 /* AnyKeyword */: - case 128 /* StringKeyword */: - case 126 /* NumberKeyword */: - case 118 /* BooleanKeyword */: - case 129 /* SymbolKeyword */: + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 101 /* VoidKeyword */: + case 103 /* VoidKeyword */: + case 97 /* ThisKeyword */: return parseTokenNode(); - case 99 /* TypeOfKeyword */: + case 101 /* TypeOfKeyword */: return parseTypeQuery(); case 15 /* OpenBraceToken */: return parseTypeLiteral(); @@ -9276,17 +9450,18 @@ var ts; } function isStartOfType() { switch (token) { - case 115 /* AnyKeyword */: - case 128 /* StringKeyword */: - case 126 /* NumberKeyword */: - case 118 /* BooleanKeyword */: - case 129 /* SymbolKeyword */: - case 101 /* VoidKeyword */: - case 99 /* TypeOfKeyword */: + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: + case 97 /* ThisKeyword */: + case 101 /* TypeOfKeyword */: case 15 /* OpenBraceToken */: case 19 /* OpenBracketToken */: case 25 /* LessThanToken */: - case 90 /* NewKeyword */: + case 92 /* NewKeyword */: return true; case 17 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, @@ -9304,7 +9479,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { parseExpected(20 /* CloseBracketToken */); - var node = createNode(154 /* ArrayType */, type.pos); + var node = createNode(156 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -9326,10 +9501,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(157 /* IntersectionType */, parseArrayTypeOrHigher, 45 /* AmpersandToken */); + return parseUnionOrIntersectionType(159 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(156 /* UnionType */, parseIntersectionTypeOrHigher, 46 /* BarToken */); + return parseUnionOrIntersectionType(158 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */); } function isStartOfFunctionType() { if (token === 25 /* LessThanToken */) { @@ -9346,8 +9521,8 @@ var ts; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 53 /* ColonToken */ || token === 24 /* CommaToken */ || - token === 52 /* QuestionToken */ || token === 55 /* EqualsToken */ || + if (token === 54 /* ColonToken */ || token === 24 /* CommaToken */ || + token === 53 /* QuestionToken */ || token === 56 /* EqualsToken */ || isIdentifier() || ts.isModifier(token)) { // ( id : // ( id , @@ -9373,24 +9548,24 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(150 /* FunctionType */); + return parseFunctionOrConstructorType(152 /* FunctionType */); } - if (token === 90 /* NewKeyword */) { - return parseFunctionOrConstructorType(151 /* ConstructorType */); + if (token === 92 /* NewKeyword */) { + return parseFunctionOrConstructorType(153 /* ConstructorType */); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(53 /* ColonToken */) ? parseType() : undefined; + return parseOptional(54 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token) { - case 95 /* ThisKeyword */: - case 93 /* SuperKeyword */: - case 91 /* NullKeyword */: - case 97 /* TrueKeyword */: - case 82 /* FalseKeyword */: + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: + case 93 /* NullKeyword */: + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 11 /* NoSubstitutionTemplateLiteral */: @@ -9398,12 +9573,12 @@ var ts; case 17 /* OpenParenToken */: case 19 /* OpenBracketToken */: case 15 /* OpenBraceToken */: - case 85 /* FunctionKeyword */: - case 71 /* ClassKeyword */: - case 90 /* NewKeyword */: - case 38 /* SlashToken */: - case 59 /* SlashEqualsToken */: - case 67 /* Identifier */: + case 87 /* FunctionKeyword */: + case 73 /* ClassKeyword */: + case 92 /* NewKeyword */: + case 39 /* SlashToken */: + case 61 /* SlashEqualsToken */: + case 69 /* Identifier */: return true; default: return isIdentifier(); @@ -9416,16 +9591,16 @@ var ts; switch (token) { case 35 /* PlusToken */: case 36 /* MinusToken */: - case 49 /* TildeToken */: - case 48 /* ExclamationToken */: - case 76 /* DeleteKeyword */: - case 99 /* TypeOfKeyword */: - case 101 /* VoidKeyword */: - case 40 /* PlusPlusToken */: - case 41 /* MinusMinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: + case 78 /* DeleteKeyword */: + case 101 /* TypeOfKeyword */: + case 103 /* VoidKeyword */: + case 41 /* PlusPlusToken */: + case 42 /* MinusMinusToken */: case 25 /* LessThanToken */: - case 117 /* AwaitKeyword */: - case 112 /* YieldKeyword */: + case 119 /* AwaitKeyword */: + case 114 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -9444,9 +9619,9 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token !== 15 /* OpenBraceToken */ && - token !== 85 /* FunctionKeyword */ && - token !== 71 /* ClassKeyword */ && - token !== 54 /* AtToken */ && + token !== 87 /* FunctionKeyword */ && + token !== 73 /* ClassKeyword */ && + token !== 55 /* AtToken */ && isStartOfExpression(); } function allowInAndParseExpression() { @@ -9472,7 +9647,7 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 55 /* EqualsToken */) { + if (token !== 56 /* EqualsToken */) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse // this as an equals-value clause with a missing equals. @@ -9489,7 +9664,7 @@ var ts; } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(55 /* EqualsToken */); + parseExpected(56 /* EqualsToken */); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -9527,7 +9702,7 @@ var ts; // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 67 /* Identifier */ && token === 34 /* EqualsGreaterThanToken */) { + if (expr.kind === 69 /* Identifier */ && token === 34 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -9543,7 +9718,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 112 /* YieldKeyword */) { + if (token === 114 /* YieldKeyword */) { // If we have a 'yield' keyword, and htis is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -9572,7 +9747,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(182 /* YieldExpression */); + var node = createNode(184 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -9592,8 +9767,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(172 /* ArrowFunction */, identifier.pos); - var parameter = createNode(136 /* Parameter */, identifier.pos); + var node = createNode(174 /* ArrowFunction */, identifier.pos); + var parameter = createNode(138 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -9635,7 +9810,7 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */ || token === 116 /* AsyncKeyword */) { + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */ || token === 118 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } if (token === 34 /* EqualsGreaterThanToken */) { @@ -9648,7 +9823,7 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 116 /* AsyncKeyword */) { + if (token === 118 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; @@ -9668,7 +9843,7 @@ var ts; var third = nextToken(); switch (third) { case 34 /* EqualsGreaterThanToken */: - case 53 /* ColonToken */: + case 54 /* ColonToken */: case 15 /* OpenBraceToken */: return 1 /* True */; default: @@ -9699,7 +9874,7 @@ var ts; } // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - if (nextToken() === 53 /* ColonToken */) { + if (nextToken() === 54 /* ColonToken */) { return 1 /* True */; } // This *could* be a parenthesized arrow function. @@ -9717,10 +9892,10 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 81 /* ExtendsKeyword */) { + if (third === 83 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 55 /* EqualsToken */: + case 56 /* EqualsToken */: case 27 /* GreaterThanToken */: return false; default: @@ -9745,7 +9920,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(172 /* ArrowFunction */); + var node = createNode(174 /* ArrowFunction */); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512 /* Async */); // Arrow functions are never generators. @@ -9755,7 +9930,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { return undefined; @@ -9779,8 +9954,8 @@ var ts; return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); } if (token !== 23 /* SemicolonToken */ && - token !== 85 /* FunctionKeyword */ && - token !== 71 /* ClassKeyword */ && + token !== 87 /* FunctionKeyword */ && + token !== 73 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -9805,17 +9980,17 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(52 /* QuestionToken */); + var questionToken = parseOptionalToken(53 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(180 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(182 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(53 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(53 /* ColonToken */)); + node.colonToken = parseExpectedToken(54 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(54 /* ColonToken */)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -9824,7 +9999,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 88 /* InKeyword */ || t === 132 /* OfKeyword */; + return t === 90 /* InKeyword */ || t === 134 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -9833,13 +10008,36 @@ var ts; reScanGreaterToken(); var newPrecedence = getBinaryOperatorPrecedence(); // Check the precedence to see if we should "take" this operator - if (newPrecedence <= precedence) { + // - For left associative operator (all operator but **), consume the operator, + // recursively call the function below, and parse binaryExpression as a rightOperand + // of the caller if the new precendence of the operator is greater then or equal to the current precendence. + // For example: + // a - b - c; + // ^token; leftOperand = b. Return b to the caller as a rightOperand + // a * b - c + // ^token; leftOperand = b. Return b to the caller as a rightOperand + // a - b * c; + // ^token; leftOperand = b. Return b * c to the caller as a rightOperand + // - For right associative operator (**), consume the operator, recursively call the function + // and parse binaryExpression as a rightOperand of the caller if the new precendence of + // the operator is strictly grater than the current precendence + // For example: + // a ** b ** c; + // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand + // a - b ** c; + // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand + // a ** b - c + // ^token; leftOperand = b. Return b to the caller as a rightOperand + var consumeCurrentOperator = token === 38 /* AsteriskAsteriskToken */ ? + newPrecedence >= precedence : + newPrecedence > precedence; + if (!consumeCurrentOperator) { break; } - if (token === 88 /* InKeyword */ && inDisallowInContext()) { + if (token === 90 /* InKeyword */ && inDisallowInContext()) { break; } - if (token === 114 /* AsKeyword */) { + if (token === 116 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -9860,22 +10058,22 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 88 /* InKeyword */) { + if (inDisallowInContext() && token === 90 /* InKeyword */) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 51 /* BarBarToken */: + case 52 /* BarBarToken */: return 1; - case 50 /* AmpersandAmpersandToken */: + case 51 /* AmpersandAmpersandToken */: return 2; - case 46 /* BarToken */: + case 47 /* BarToken */: return 3; - case 47 /* CaretToken */: + case 48 /* CaretToken */: return 4; - case 45 /* AmpersandToken */: + case 46 /* AmpersandToken */: return 5; case 30 /* EqualsEqualsToken */: case 31 /* ExclamationEqualsToken */: @@ -9886,66 +10084,68 @@ var ts; case 27 /* GreaterThanToken */: case 28 /* LessThanEqualsToken */: case 29 /* GreaterThanEqualsToken */: - case 89 /* InstanceOfKeyword */: - case 88 /* InKeyword */: - case 114 /* AsKeyword */: + case 91 /* InstanceOfKeyword */: + case 90 /* InKeyword */: + case 116 /* AsKeyword */: return 7; - case 42 /* LessThanLessThanToken */: - case 43 /* GreaterThanGreaterThanToken */: - case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 43 /* LessThanLessThanToken */: + case 44 /* GreaterThanGreaterThanToken */: + case 45 /* GreaterThanGreaterThanGreaterThanToken */: return 8; case 35 /* PlusToken */: case 36 /* MinusToken */: return 9; case 37 /* AsteriskToken */: - case 38 /* SlashToken */: - case 39 /* PercentToken */: + case 39 /* SlashToken */: + case 40 /* PercentToken */: return 10; + case 38 /* AsteriskAsteriskToken */: + return 11; } // -1 is lower than all other precedences. Returning it will cause binary expression // parsing to stop. return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(179 /* BinaryExpression */, left.pos); + var node = createNode(181 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(187 /* AsExpression */, left.pos); + var node = createNode(189 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(177 /* PrefixUnaryExpression */); + var node = createNode(179 /* PrefixUnaryExpression */); node.operator = token; nextToken(); - node.operand = parseUnaryExpressionOrHigher(); + node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(173 /* DeleteExpression */); + var node = createNode(175 /* DeleteExpression */); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(174 /* TypeOfExpression */); + var node = createNode(176 /* TypeOfExpression */); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(175 /* VoidExpression */); + var node = createNode(177 /* VoidExpression */); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token === 117 /* AwaitKeyword */) { + if (token === 119 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -9955,46 +10155,137 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(176 /* AwaitExpression */); + var node = createNode(178 /* AwaitExpression */); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + /** + * Parse ES7 unary expression and await expression + * + * ES7 UnaryExpression: + * 1) SimpleUnaryExpression[?yield] + * 2) IncrementExpression[?yield] ** UnaryExpression[?yield] + */ function parseUnaryExpressionOrHigher() { if (isAwaitExpression()) { return parseAwaitExpression(); } + if (isIncrementExpression()) { + var incrementExpression = parseIncrementExpression(); + return token === 38 /* AsteriskAsteriskToken */ ? + parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : + incrementExpression; + } + var unaryOperator = token; + var simpleUnaryExpression = parseSimpleUnaryExpression(); + if (token === 38 /* AsteriskAsteriskToken */) { + var diagnostic; + var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); + if (simpleUnaryExpression.kind === 171 /* TypeAssertionExpression */) { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); + } + else { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, ts.tokenToString(unaryOperator)); + } + } + return simpleUnaryExpression; + } + /** + * Parse ES7 simple-unary expression or higher: + * + * ES7 SimpleUnaryExpression: + * 1) IncrementExpression[?yield] + * 2) delete UnaryExpression[?yield] + * 3) void UnaryExpression[?yield] + * 4) typeof UnaryExpression[?yield] + * 5) + UnaryExpression[?yield] + * 6) - UnaryExpression[?yield] + * 7) ~ UnaryExpression[?yield] + * 8) ! UnaryExpression[?yield] + */ + function parseSimpleUnaryExpression() { switch (token) { case 35 /* PlusToken */: case 36 /* MinusToken */: - case 49 /* TildeToken */: - case 48 /* ExclamationToken */: - case 40 /* PlusPlusToken */: - case 41 /* MinusMinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 76 /* DeleteKeyword */: + case 78 /* DeleteKeyword */: return parseDeleteExpression(); - case 99 /* TypeOfKeyword */: + case 101 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 101 /* VoidKeyword */: + case 103 /* VoidKeyword */: return parseVoidExpression(); case 25 /* LessThanToken */: + // This is modified UnaryExpression grammar in TypeScript + // UnaryExpression (modified): + // < type > UnaryExpression + return parseTypeAssertion(); + default: + return parseIncrementExpression(); + } + } + /** + * Check if the current token can possibly be an ES7 increment expression. + * + * ES7 IncrementExpression: + * LeftHandSideExpression[?Yield] + * LeftHandSideExpression[?Yield][no LineTerminator here]++ + * LeftHandSideExpression[?Yield][no LineTerminator here]-- + * ++LeftHandSideExpression[?Yield] + * --LeftHandSideExpression[?Yield] + */ + function isIncrementExpression() { + // This function is called inside parseUnaryExpression to decide + // whether to call parseSimpleUnaryExpression or call parseIncrmentExpression directly + switch (token) { + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: + case 78 /* DeleteKeyword */: + case 101 /* TypeOfKeyword */: + case 103 /* VoidKeyword */: + return false; + case 25 /* LessThanToken */: + // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { - return parseTypeAssertion(); - } - if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); + return false; } + // We are in JSX context and the token is part of JSXElement. // Fall through default: - return parsePostfixExpressionOrHigher(); + return true; } } - function parsePostfixExpressionOrHigher() { + /** + * Parse ES7 IncrementExpression. IncrementExpression is used instead of ES6's PostFixExpression. + * + * ES7 IncrementExpression[yield]: + * 1) LeftHandSideExpression[?yield] + * 2) LeftHandSideExpression[?yield] [[no LineTerminator here]]++ + * 3) LeftHandSideExpression[?yield] [[no LineTerminator here]]-- + * 4) ++LeftHandSideExpression[?yield] + * 5) --LeftHandSideExpression[?yield] + * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression + */ + function parseIncrementExpression() { + if (token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) { + var node = createNode(179 /* PrefixUnaryExpression */); + node.operator = token; + nextToken(); + node.operand = parseLeftHandSideExpressionOrHigher(); + return finishNode(node); + } + else if (sourceFile.languageVariant === 1 /* JSX */ && token === 25 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeyword)) { + // JSXElement is part of primaryExpression + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); + } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 40 /* PlusPlusToken */ || token === 41 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(178 /* PostfixUnaryExpression */, expression.pos); + if ((token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(180 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -10033,7 +10324,7 @@ var ts; // the last two CallExpression productions. Or we have a MemberExpression which either // completes the LeftHandSideExpression, or starts the beginning of the first four // CallExpression productions. - var expression = token === 93 /* SuperKeyword */ + var expression = token === 95 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); // Now, we *may* be complete. However, we might have consumed the start of a @@ -10098,7 +10389,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(164 /* PropertyAccessExpression */, expression.pos); + var node = createNode(166 /* PropertyAccessExpression */, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -10106,27 +10397,27 @@ var ts; } function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); - if (opening.kind === 233 /* JsxOpeningElement */) { - var node = createNode(231 /* JsxElement */, opening.pos); + if (opening.kind === 235 /* JsxOpeningElement */) { + var node = createNode(233 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 232 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 234 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements return opening; } } function parseJsxText() { - var node = createNode(234 /* JsxText */, scanner.getStartPos()); + var node = createNode(236 /* JsxText */, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 234 /* JsxText */: + case 236 /* JsxText */: return parseJsxText(); case 15 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); @@ -10165,11 +10456,11 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(233 /* JsxOpeningElement */, fullStart); + node = createNode(235 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(38 /* SlashToken */); + parseExpected(39 /* SlashToken */); if (inExpressionContext) { parseExpected(27 /* GreaterThanToken */); } @@ -10177,7 +10468,7 @@ var ts; parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); scanJsxText(); } - node = createNode(232 /* JsxSelfClosingElement */, fullStart); + node = createNode(234 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -10188,7 +10479,7 @@ var ts; var elementName = parseIdentifierName(); while (parseOptional(21 /* DotToken */)) { scanJsxIdentifier(); - var node = createNode(133 /* QualifiedName */, elementName.pos); + var node = createNode(135 /* QualifiedName */, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); @@ -10196,7 +10487,7 @@ var ts; return elementName; } function parseJsxExpression(inExpressionContext) { - var node = createNode(238 /* JsxExpression */); + var node = createNode(240 /* JsxExpression */); parseExpected(15 /* OpenBraceToken */); if (token !== 16 /* CloseBraceToken */) { node.expression = parseExpression(); @@ -10215,9 +10506,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(236 /* JsxAttribute */); + var node = createNode(238 /* JsxAttribute */); node.name = parseIdentifierName(); - if (parseOptional(55 /* EqualsToken */)) { + if (parseOptional(56 /* EqualsToken */)) { switch (token) { case 9 /* StringLiteral */: node.initializer = parseLiteralNode(); @@ -10230,7 +10521,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(237 /* JsxSpreadAttribute */); + var node = createNode(239 /* JsxSpreadAttribute */); parseExpected(15 /* OpenBraceToken */); parseExpected(22 /* DotDotDotToken */); node.expression = parseExpression(); @@ -10238,7 +10529,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(235 /* JsxClosingElement */); + var node = createNode(237 /* JsxClosingElement */); parseExpected(26 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -10251,18 +10542,18 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(169 /* TypeAssertionExpression */); + var node = createNode(171 /* TypeAssertionExpression */); parseExpected(25 /* LessThanToken */); node.type = parseType(); parseExpected(27 /* GreaterThanToken */); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { var dotToken = parseOptionalToken(21 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(164 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(166 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -10271,7 +10562,7 @@ var ts; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(19 /* OpenBracketToken */)) { - var indexedAccess = createNode(165 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(167 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". // Check for that common pattern and report a better error message. @@ -10287,7 +10578,7 @@ var ts; continue; } if (token === 11 /* NoSubstitutionTemplateLiteral */ || token === 12 /* TemplateHead */) { - var tagExpression = createNode(168 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(170 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 11 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -10310,7 +10601,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(166 /* CallExpression */, expression.pos); + var callExpr = createNode(168 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -10318,7 +10609,7 @@ var ts; continue; } else if (token === 17 /* OpenParenToken */) { - var callExpr = createNode(166 /* CallExpression */, expression.pos); + var callExpr = createNode(168 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -10356,18 +10647,18 @@ var ts; case 21 /* DotToken */: // foo. case 18 /* CloseParenToken */: // foo) case 20 /* CloseBracketToken */: // foo] - case 53 /* ColonToken */: // foo: + case 54 /* ColonToken */: // foo: case 23 /* SemicolonToken */: // foo; - case 52 /* QuestionToken */: // foo? + case 53 /* QuestionToken */: // foo? case 30 /* EqualsEqualsToken */: // foo == case 32 /* EqualsEqualsEqualsToken */: // foo === case 31 /* ExclamationEqualsToken */: // foo != case 33 /* ExclamationEqualsEqualsToken */: // foo !== - case 50 /* AmpersandAmpersandToken */: // foo && - case 51 /* BarBarToken */: // foo || - case 47 /* CaretToken */: // foo ^ - case 45 /* AmpersandToken */: // foo & - case 46 /* BarToken */: // foo | + case 51 /* AmpersandAmpersandToken */: // foo && + case 52 /* BarBarToken */: // foo || + case 48 /* CaretToken */: // foo ^ + case 46 /* AmpersandToken */: // foo & + case 47 /* BarToken */: // foo | case 16 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal @@ -10390,11 +10681,11 @@ var ts; case 9 /* StringLiteral */: case 11 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 95 /* ThisKeyword */: - case 93 /* SuperKeyword */: - case 91 /* NullKeyword */: - case 97 /* TrueKeyword */: - case 82 /* FalseKeyword */: + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: + case 93 /* NullKeyword */: + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: return parseTokenNode(); case 17 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -10402,7 +10693,7 @@ var ts; return parseArrayLiteralExpression(); case 15 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 116 /* AsyncKeyword */: + case 118 /* AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -10410,14 +10701,14 @@ var ts; break; } return parseFunctionExpression(); - case 71 /* ClassKeyword */: + case 73 /* ClassKeyword */: return parseClassExpression(); - case 85 /* FunctionKeyword */: + case 87 /* FunctionKeyword */: return parseFunctionExpression(); - case 90 /* NewKeyword */: + case 92 /* NewKeyword */: return parseNewExpression(); - case 38 /* SlashToken */: - case 59 /* SlashEqualsToken */: + case 39 /* SlashToken */: + case 61 /* SlashEqualsToken */: if (reScanSlashToken() === 10 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -10428,28 +10719,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(170 /* ParenthesizedExpression */); + var node = createNode(172 /* ParenthesizedExpression */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(183 /* SpreadElementExpression */); + var node = createNode(185 /* SpreadElementExpression */); parseExpected(22 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 22 /* DotDotDotToken */ ? parseSpreadElement() : - token === 24 /* CommaToken */ ? createNode(185 /* OmittedExpression */) : + token === 24 /* CommaToken */ ? createNode(187 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(162 /* ArrayLiteralExpression */); + var node = createNode(164 /* ArrayLiteralExpression */); parseExpected(19 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048 /* MultiLine */; @@ -10458,11 +10749,11 @@ var ts; return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(121 /* GetKeyword */)) { - return parseAccessorDeclaration(143 /* GetAccessor */, fullStart, decorators, modifiers); + if (parseContextualModifier(123 /* GetKeyword */)) { + return parseAccessorDeclaration(145 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(127 /* SetKeyword */)) { - return parseAccessorDeclaration(144 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(129 /* SetKeyword */)) { + return parseAccessorDeclaration(146 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -10479,28 +10770,38 @@ var ts; var nameToken = token; var propertyName = parsePropertyName(); // Disallowing of optional property assignments happens in the grammar checker. - var questionToken = parseOptionalToken(52 /* QuestionToken */); + var questionToken = parseOptionalToken(53 /* QuestionToken */); if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - // Parse to check if it is short-hand property assignment or normal property assignment - if ((token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(244 /* ShorthandPropertyAssignment */, fullStart); + // check if it is short-hand property assignment or normal property assignment + // NOTE: if token is EqualsToken it is interpreted as CoverInitializedName production + // CoverInitializedName[Yield] : + // IdentifierReference[?Yield] Initializer[In, ?Yield] + // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern + var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */ || token === 56 /* EqualsToken */); + if (isShorthandPropertyAssignment) { + var shorthandDeclaration = createNode(246 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; + var equalsToken = parseOptionalToken(56 /* EqualsToken */); + if (equalsToken) { + shorthandDeclaration.equalsToken = equalsToken; + shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); + } return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(243 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(245 /* PropertyAssignment */, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(53 /* ColonToken */); + parseExpected(54 /* ColonToken */); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(163 /* ObjectLiteralExpression */); + var node = createNode(165 /* ObjectLiteralExpression */); parseExpected(15 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048 /* MultiLine */; @@ -10519,9 +10820,9 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(171 /* FunctionExpression */); + var node = createNode(173 /* FunctionExpression */); setModifiers(node, parseModifiers()); - parseExpected(85 /* FunctionKeyword */); + parseExpected(87 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512 /* Async */); @@ -10530,7 +10831,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -10541,8 +10842,8 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(167 /* NewExpression */); - parseExpected(90 /* NewKeyword */); + var node = createNode(169 /* NewExpression */); + parseExpected(92 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token === 17 /* OpenParenToken */) { @@ -10552,7 +10853,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(190 /* Block */); + var node = createNode(192 /* Block */); if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(16 /* CloseBraceToken */); @@ -10582,25 +10883,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(192 /* EmptyStatement */); + var node = createNode(194 /* EmptyStatement */); parseExpected(23 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(194 /* IfStatement */); - parseExpected(86 /* IfKeyword */); + var node = createNode(196 /* IfStatement */); + parseExpected(88 /* IfKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(78 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(80 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(195 /* DoStatement */); - parseExpected(77 /* DoKeyword */); + var node = createNode(197 /* DoStatement */); + parseExpected(79 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(102 /* WhileKeyword */); + parseExpected(104 /* WhileKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); @@ -10612,8 +10913,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(196 /* WhileStatement */); - parseExpected(102 /* WhileKeyword */); + var node = createNode(198 /* WhileStatement */); + parseExpected(104 /* WhileKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); @@ -10622,11 +10923,11 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(84 /* ForKeyword */); + parseExpected(86 /* ForKeyword */); parseExpected(17 /* OpenParenToken */); var initializer = undefined; if (token !== 23 /* SemicolonToken */) { - if (token === 100 /* VarKeyword */ || token === 106 /* LetKeyword */ || token === 72 /* ConstKeyword */) { + if (token === 102 /* VarKeyword */ || token === 108 /* LetKeyword */ || token === 74 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -10634,22 +10935,22 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(88 /* InKeyword */)) { - var forInStatement = createNode(198 /* ForInStatement */, pos); + if (parseOptional(90 /* InKeyword */)) { + var forInStatement = createNode(200 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(132 /* OfKeyword */)) { - var forOfStatement = createNode(199 /* ForOfStatement */, pos); + else if (parseOptional(134 /* OfKeyword */)) { + var forOfStatement = createNode(201 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(197 /* ForStatement */, pos); + var forStatement = createNode(199 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(23 /* SemicolonToken */); if (token !== 23 /* SemicolonToken */ && token !== 18 /* CloseParenToken */) { @@ -10667,7 +10968,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */); + parseExpected(kind === 203 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -10675,8 +10976,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(202 /* ReturnStatement */); - parseExpected(92 /* ReturnKeyword */); + var node = createNode(204 /* ReturnStatement */); + parseExpected(94 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -10684,8 +10985,8 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(203 /* WithStatement */); - parseExpected(103 /* WithKeyword */); + var node = createNode(205 /* WithStatement */); + parseExpected(105 /* WithKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); @@ -10693,30 +10994,30 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(239 /* CaseClause */); - parseExpected(69 /* CaseKeyword */); + var node = createNode(241 /* CaseClause */); + parseExpected(71 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(53 /* ColonToken */); + parseExpected(54 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(240 /* DefaultClause */); - parseExpected(75 /* DefaultKeyword */); - parseExpected(53 /* ColonToken */); + var node = createNode(242 /* DefaultClause */); + parseExpected(77 /* DefaultKeyword */); + parseExpected(54 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 69 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token === 71 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(204 /* SwitchStatement */); - parseExpected(94 /* SwitchKeyword */); + var node = createNode(206 /* SwitchStatement */); + parseExpected(96 /* SwitchKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); - var caseBlock = createNode(218 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(220 /* CaseBlock */, scanner.getStartPos()); parseExpected(15 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(16 /* CloseBraceToken */); @@ -10731,29 +11032,29 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(206 /* ThrowStatement */); - parseExpected(96 /* ThrowKeyword */); + var node = createNode(208 /* ThrowStatement */); + parseExpected(98 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(207 /* TryStatement */); - parseExpected(98 /* TryKeyword */); + var node = createNode(209 /* TryStatement */); + parseExpected(100 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token === 70 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token === 72 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token === 83 /* FinallyKeyword */) { - parseExpected(83 /* FinallyKeyword */); + if (!node.catchClause || token === 85 /* FinallyKeyword */) { + parseExpected(85 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(242 /* CatchClause */); - parseExpected(70 /* CatchKeyword */); + var result = createNode(244 /* CatchClause */); + parseExpected(72 /* CatchKeyword */); if (parseExpected(17 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } @@ -10762,8 +11063,8 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(208 /* DebuggerStatement */); - parseExpected(74 /* DebuggerKeyword */); + var node = createNode(210 /* DebuggerStatement */); + parseExpected(76 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -10773,14 +11074,14 @@ var ts; // a colon. var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 67 /* Identifier */ && parseOptional(53 /* ColonToken */)) { - var labeledStatement = createNode(205 /* LabeledStatement */, fullStart); + if (expression.kind === 69 /* Identifier */ && parseOptional(54 /* ColonToken */)) { + var labeledStatement = createNode(207 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(193 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(195 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -10792,7 +11093,7 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 85 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token === 87 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -10801,12 +11102,12 @@ var ts; function isDeclaration() { while (true) { switch (token) { - case 100 /* VarKeyword */: - case 106 /* LetKeyword */: - case 72 /* ConstKeyword */: - case 85 /* FunctionKeyword */: - case 71 /* ClassKeyword */: - case 79 /* EnumKeyword */: + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: + case 87 /* FunctionKeyword */: + case 73 /* ClassKeyword */: + case 81 /* EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -10829,36 +11130,36 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 105 /* InterfaceKeyword */: - case 130 /* TypeKeyword */: + case 107 /* InterfaceKeyword */: + case 132 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 123 /* ModuleKeyword */: - case 124 /* NamespaceKeyword */: + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 116 /* AsyncKeyword */: - case 120 /* DeclareKeyword */: + case 115 /* AbstractKeyword */: + case 118 /* AsyncKeyword */: + case 122 /* DeclareKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 112 /* PublicKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 87 /* ImportKeyword */: + case 89 /* ImportKeyword */: nextToken(); return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ || token === 15 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token); - case 80 /* ExportKeyword */: + case 82 /* ExportKeyword */: nextToken(); - if (token === 55 /* EqualsToken */ || token === 37 /* AsteriskToken */ || - token === 15 /* OpenBraceToken */ || token === 75 /* DefaultKeyword */) { + if (token === 56 /* EqualsToken */ || token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */ || token === 77 /* DefaultKeyword */) { return true; } continue; - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 111 /* StaticKeyword */: - case 113 /* AbstractKeyword */: + case 113 /* StaticKeyword */: nextToken(); continue; default: @@ -10871,47 +11172,47 @@ var ts; } function isStartOfStatement() { switch (token) { - case 54 /* AtToken */: + case 55 /* AtToken */: case 23 /* SemicolonToken */: case 15 /* OpenBraceToken */: - case 100 /* VarKeyword */: - case 106 /* LetKeyword */: - case 85 /* FunctionKeyword */: - case 71 /* ClassKeyword */: - case 79 /* EnumKeyword */: - case 86 /* IfKeyword */: - case 77 /* DoKeyword */: - case 102 /* WhileKeyword */: - case 84 /* ForKeyword */: - case 73 /* ContinueKeyword */: - case 68 /* BreakKeyword */: - case 92 /* ReturnKeyword */: - case 103 /* WithKeyword */: - case 94 /* SwitchKeyword */: - case 96 /* ThrowKeyword */: - case 98 /* TryKeyword */: - case 74 /* DebuggerKeyword */: + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 87 /* FunctionKeyword */: + case 73 /* ClassKeyword */: + case 81 /* EnumKeyword */: + case 88 /* IfKeyword */: + case 79 /* DoKeyword */: + case 104 /* WhileKeyword */: + case 86 /* ForKeyword */: + case 75 /* ContinueKeyword */: + case 70 /* BreakKeyword */: + case 94 /* ReturnKeyword */: + case 105 /* WithKeyword */: + case 96 /* SwitchKeyword */: + case 98 /* ThrowKeyword */: + case 100 /* TryKeyword */: + case 76 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 70 /* CatchKeyword */: - case 83 /* FinallyKeyword */: + case 72 /* CatchKeyword */: + case 85 /* FinallyKeyword */: return true; - case 72 /* ConstKeyword */: - case 80 /* ExportKeyword */: - case 87 /* ImportKeyword */: + case 74 /* ConstKeyword */: + case 82 /* ExportKeyword */: + case 89 /* ImportKeyword */: return isStartOfDeclaration(); - case 116 /* AsyncKeyword */: - case 120 /* DeclareKeyword */: - case 105 /* InterfaceKeyword */: - case 123 /* ModuleKeyword */: - case 124 /* NamespaceKeyword */: - case 130 /* TypeKeyword */: + case 118 /* AsyncKeyword */: + case 122 /* DeclareKeyword */: + case 107 /* InterfaceKeyword */: + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: + case 132 /* TypeKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 111 /* StaticKeyword */: + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 113 /* StaticKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -10934,61 +11235,61 @@ var ts; return parseEmptyStatement(); case 15 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 100 /* VarKeyword */: + case 102 /* VarKeyword */: return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 106 /* LetKeyword */: + case 108 /* LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 85 /* FunctionKeyword */: + case 87 /* FunctionKeyword */: return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 71 /* ClassKeyword */: + case 73 /* ClassKeyword */: return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 86 /* IfKeyword */: + case 88 /* IfKeyword */: return parseIfStatement(); - case 77 /* DoKeyword */: + case 79 /* DoKeyword */: return parseDoStatement(); - case 102 /* WhileKeyword */: + case 104 /* WhileKeyword */: return parseWhileStatement(); - case 84 /* ForKeyword */: + case 86 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 73 /* ContinueKeyword */: - return parseBreakOrContinueStatement(200 /* ContinueStatement */); - case 68 /* BreakKeyword */: - return parseBreakOrContinueStatement(201 /* BreakStatement */); - case 92 /* ReturnKeyword */: + case 75 /* ContinueKeyword */: + return parseBreakOrContinueStatement(202 /* ContinueStatement */); + case 70 /* BreakKeyword */: + return parseBreakOrContinueStatement(203 /* BreakStatement */); + case 94 /* ReturnKeyword */: return parseReturnStatement(); - case 103 /* WithKeyword */: + case 105 /* WithKeyword */: return parseWithStatement(); - case 94 /* SwitchKeyword */: + case 96 /* SwitchKeyword */: return parseSwitchStatement(); - case 96 /* ThrowKeyword */: + case 98 /* ThrowKeyword */: return parseThrowStatement(); - case 98 /* TryKeyword */: + case 100 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 70 /* CatchKeyword */: - case 83 /* FinallyKeyword */: + case 72 /* CatchKeyword */: + case 85 /* FinallyKeyword */: return parseTryStatement(); - case 74 /* DebuggerKeyword */: + case 76 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 54 /* AtToken */: + case 55 /* AtToken */: return parseDeclaration(); - case 116 /* AsyncKeyword */: - case 105 /* InterfaceKeyword */: - case 130 /* TypeKeyword */: - case 123 /* ModuleKeyword */: - case 124 /* NamespaceKeyword */: - case 120 /* DeclareKeyword */: - case 72 /* ConstKeyword */: - case 79 /* EnumKeyword */: - case 80 /* ExportKeyword */: - case 87 /* ImportKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 110 /* PublicKeyword */: - case 113 /* AbstractKeyword */: - case 111 /* StaticKeyword */: + case 118 /* AsyncKeyword */: + case 107 /* InterfaceKeyword */: + case 132 /* TypeKeyword */: + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: + case 122 /* DeclareKeyword */: + case 74 /* ConstKeyword */: + case 81 /* EnumKeyword */: + case 82 /* ExportKeyword */: + case 89 /* ImportKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 112 /* PublicKeyword */: + case 115 /* AbstractKeyword */: + case 113 /* StaticKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -11001,35 +11302,35 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 100 /* VarKeyword */: - case 106 /* LetKeyword */: - case 72 /* ConstKeyword */: + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: return parseVariableStatement(fullStart, decorators, modifiers); - case 85 /* FunctionKeyword */: + case 87 /* FunctionKeyword */: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 71 /* ClassKeyword */: + case 73 /* ClassKeyword */: return parseClassDeclaration(fullStart, decorators, modifiers); - case 105 /* InterfaceKeyword */: + case 107 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 130 /* TypeKeyword */: + case 132 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 79 /* EnumKeyword */: + case 81 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 123 /* ModuleKeyword */: - case 124 /* NamespaceKeyword */: + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 87 /* ImportKeyword */: + case 89 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 80 /* ExportKeyword */: + case 82 /* ExportKeyword */: nextToken(); - return token === 75 /* DefaultKeyword */ || token === 55 /* EqualsToken */ ? + return token === 77 /* DefaultKeyword */ || token === 56 /* EqualsToken */ ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(229 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(231 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -11051,24 +11352,24 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token === 24 /* CommaToken */) { - return createNode(185 /* OmittedExpression */); + return createNode(187 /* OmittedExpression */); } - var node = createNode(161 /* BindingElement */); + var node = createNode(163 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(161 /* BindingElement */); + var node = createNode(163 /* BindingElement */); // TODO(andersh): Handle computed properties var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 53 /* ColonToken */) { + if (tokenIsIdentifier && token !== 54 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(53 /* ColonToken */); + parseExpected(54 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -11076,14 +11377,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(159 /* ObjectBindingPattern */); + var node = createNode(161 /* ObjectBindingPattern */); parseExpected(15 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(16 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(160 /* ArrayBindingPattern */); + var node = createNode(162 /* ArrayBindingPattern */); parseExpected(19 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(20 /* CloseBracketToken */); @@ -11102,7 +11403,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(209 /* VariableDeclaration */); + var node = createNode(211 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -11111,14 +11412,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(210 /* VariableDeclarationList */); + var node = createNode(212 /* VariableDeclarationList */); switch (token) { - case 100 /* VarKeyword */: + case 102 /* VarKeyword */: break; - case 106 /* LetKeyword */: + case 108 /* LetKeyword */: node.flags |= 16384 /* Let */; break; - case 72 /* ConstKeyword */: + case 74 /* ConstKeyword */: node.flags |= 32768 /* Const */; break; default: @@ -11134,7 +11435,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token === 132 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 134 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -11149,7 +11450,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(191 /* VariableStatement */, fullStart); + var node = createNode(193 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -11157,29 +11458,29 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(211 /* FunctionDeclaration */, fullStart); + var node = createNode(213 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(85 /* FunctionKeyword */); + parseExpected(87 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); node.name = node.flags & 1024 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512 /* Async */); - fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(142 /* Constructor */, pos); + var node = createNode(144 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(119 /* ConstructorKeyword */); - fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + parseExpected(121 /* ConstructorKeyword */); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(141 /* MethodDeclaration */, fullStart); + var method = createNode(143 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -11187,12 +11488,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512 /* Async */); - fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); + fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(139 /* PropertyDeclaration */, fullStart); + var property = createNode(141 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -11218,7 +11519,7 @@ var ts; var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(52 /* QuestionToken */); + var questionToken = parseOptionalToken(53 /* QuestionToken */); if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } @@ -11234,16 +11535,16 @@ var ts; node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 111 /* StaticKeyword */: + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 113 /* StaticKeyword */: return true; default: return false; @@ -11251,7 +11552,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 54 /* AtToken */) { + if (token === 55 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -11284,7 +11585,7 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 127 /* SetKeyword */ || idToken === 121 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 129 /* SetKeyword */ || idToken === 123 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -11292,9 +11593,9 @@ var ts; switch (token) { case 17 /* OpenParenToken */: // Method declaration case 25 /* LessThanToken */: // Generic Method declaration - case 53 /* ColonToken */: // Type Annotation for declaration - case 55 /* EqualsToken */: // Initializer for declaration - case 52 /* QuestionToken */: + case 54 /* ColonToken */: // Type Annotation for declaration + case 56 /* EqualsToken */: // Initializer for declaration + case 53 /* QuestionToken */: return true; default: // Covers @@ -11311,14 +11612,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(54 /* AtToken */)) { + if (!parseOptional(55 /* AtToken */)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(137 /* Decorator */, decoratorStart); + var decorator = createNode(139 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -11352,7 +11653,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 116 /* AsyncKeyword */) { + if (token === 118 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -11367,7 +11668,7 @@ var ts; } function parseClassElement() { if (token === 23 /* SemicolonToken */) { - var result = createNode(189 /* SemicolonClassElement */); + var result = createNode(191 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -11378,7 +11679,7 @@ var ts; if (accessor) { return accessor; } - if (token === 119 /* ConstructorKeyword */) { + if (token === 121 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -11395,7 +11696,7 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_7 = createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name_7 = createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. @@ -11405,17 +11706,17 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 184 /* ClassExpression */); + /*modifiers*/ undefined, 186 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 214 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(71 /* ClassKeyword */); - node.name = parseOptionalIdentifier(); + parseExpected(73 /* ClassKeyword */); + node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); if (parseExpected(15 /* OpenBraceToken */)) { @@ -11429,6 +11730,19 @@ var ts; } return finishNode(node); } + function parseNameOfClassDeclarationOrExpression() { + // implements is a future reserved word so + // 'class implements' might mean either + // - class expression with omitted name, 'implements' starts heritage clause + // - class with name 'implements' + // 'isImplementsClause' helps to disambiguate between these two cases + return isIdentifier() && !isImplementsClause() + ? parseIdentifier() + : undefined; + } + function isImplementsClause() { + return token === 106 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + } function parseHeritageClauses(isClassHeritageClause) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } @@ -11441,8 +11755,8 @@ var ts; return parseList(20 /* HeritageClauses */, parseHeritageClause); } function parseHeritageClause() { - if (token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */) { - var node = createNode(241 /* HeritageClause */); + if (token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */) { + var node = createNode(243 /* HeritageClause */); node.token = token; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -11451,7 +11765,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(186 /* ExpressionWithTypeArguments */); + var node = createNode(188 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 25 /* LessThanToken */) { node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); @@ -11459,16 +11773,16 @@ var ts; return finishNode(node); } function isHeritageClause() { - return token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; + return token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213 /* InterfaceDeclaration */, fullStart); + var node = createNode(215 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(105 /* InterfaceKeyword */); + parseExpected(107 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); @@ -11476,13 +11790,13 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214 /* TypeAliasDeclaration */, fullStart); + var node = createNode(216 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(130 /* TypeKeyword */); + parseExpected(132 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(55 /* EqualsToken */); + parseExpected(56 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -11492,16 +11806,16 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(245 /* EnumMember */, scanner.getStartPos()); + var node = createNode(247 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215 /* EnumDeclaration */, fullStart); + var node = createNode(217 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(79 /* EnumKeyword */); + parseExpected(81 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(15 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); @@ -11513,7 +11827,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(217 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(219 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(15 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(16 /* CloseBraceToken */); @@ -11524,7 +11838,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(216 /* ModuleDeclaration */, fullStart); + var node = createNode(218 /* ModuleDeclaration */, fullStart); // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 131072 /* Namespace */; @@ -11538,7 +11852,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216 /* ModuleDeclaration */, fullStart); + var node = createNode(218 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(/*internName*/ true); @@ -11547,11 +11861,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(124 /* NamespaceKeyword */)) { + if (parseOptional(126 /* NamespaceKeyword */)) { flags |= 131072 /* Namespace */; } else { - parseExpected(123 /* ModuleKeyword */); + parseExpected(125 /* ModuleKeyword */); if (token === 9 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -11559,42 +11873,42 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 125 /* RequireKeyword */ && + return token === 127 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 17 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 38 /* SlashToken */; + return nextToken() === 39 /* SlashToken */; } function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 24 /* CommaToken */ || - token === 131 /* FromKeyword */; + token === 133 /* FromKeyword */; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(87 /* ImportKeyword */); + parseExpected(89 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 24 /* CommaToken */ && token !== 131 /* FromKeyword */) { + if (token !== 24 /* CommaToken */ && token !== 133 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(219 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(221 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(55 /* EqualsToken */); + parseExpected(56 /* EqualsToken */); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } // Import statement - var importDeclaration = createNode(220 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(222 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: @@ -11604,7 +11918,7 @@ var ts; token === 37 /* AsteriskToken */ || token === 15 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(131 /* FromKeyword */); + parseExpected(133 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -11617,7 +11931,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(221 /* ImportClause */, fullStart); + var importClause = createNode(223 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -11627,7 +11941,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(24 /* CommaToken */)) { - importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(223 /* NamedImports */); + importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(225 /* NamedImports */); } return finishNode(importClause); } @@ -11637,8 +11951,8 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(230 /* ExternalModuleReference */); - parseExpected(125 /* RequireKeyword */); + var node = createNode(232 /* ExternalModuleReference */); + parseExpected(127 /* RequireKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(18 /* CloseParenToken */); @@ -11659,9 +11973,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(222 /* NamespaceImport */); + var namespaceImport = createNode(224 /* NamespaceImport */); parseExpected(37 /* AsteriskToken */); - parseExpected(114 /* AsKeyword */); + parseExpected(116 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -11674,14 +11988,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 223 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 225 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(228 /* ExportSpecifier */); + return parseImportOrExportSpecifier(230 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(224 /* ImportSpecifier */); + return parseImportOrExportSpecifier(226 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -11695,9 +12009,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 114 /* AsKeyword */) { + if (token === 116 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(114 /* AsKeyword */); + parseExpected(116 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -11706,27 +12020,27 @@ var ts; else { node.name = identifierName; } - if (kind === 224 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 226 /* ImportSpecifier */ && checkIdentifierIsKeyword) { // Report error identifier expected parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226 /* ExportDeclaration */, fullStart); + var node = createNode(228 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(37 /* AsteriskToken */)) { - parseExpected(131 /* FromKeyword */); + parseExpected(133 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(227 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(229 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token === 131 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(131 /* FromKeyword */); + if (token === 133 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(133 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -11734,14 +12048,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(225 /* ExportAssignment */, fullStart); + var node = createNode(227 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(55 /* EqualsToken */)) { + if (parseOptional(56 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(75 /* DefaultKeyword */); + parseExpected(77 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -11807,10 +12121,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ - || node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */ - || node.kind === 220 /* ImportDeclaration */ - || node.kind === 225 /* ExportAssignment */ - || node.kind === 226 /* ExportDeclaration */ + || node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 232 /* ExternalModuleReference */ + || node.kind === 222 /* ImportDeclaration */ + || node.kind === 227 /* ExportAssignment */ + || node.kind === 228 /* ExportDeclaration */ ? node : undefined; }); @@ -11856,22 +12170,22 @@ var ts; function isJSDocType() { switch (token) { case 37 /* AsteriskToken */: - case 52 /* QuestionToken */: + case 53 /* QuestionToken */: case 17 /* OpenParenToken */: case 19 /* OpenBracketToken */: - case 48 /* ExclamationToken */: + case 49 /* ExclamationToken */: case 15 /* OpenBraceToken */: - case 85 /* FunctionKeyword */: + case 87 /* FunctionKeyword */: case 22 /* DotDotDotToken */: - case 90 /* NewKeyword */: - case 95 /* ThisKeyword */: + case 92 /* NewKeyword */: + case 97 /* ThisKeyword */: return true; } return ts.tokenIsIdentifierOrKeyword(token); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); + initializeState("file.js", content, 2 /* Latest */, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined); var jsDocTypeExpression = parseJSDocTypeExpression(start, length); var diagnostics = parseDiagnostics; clearState(); @@ -11885,7 +12199,7 @@ var ts; scanner.setText(sourceText, start, length); // Prime the first token for us to start processing. token = nextToken(); - var result = createNode(247 /* JSDocTypeExpression */); + var result = createNode(249 /* JSDocTypeExpression */); parseExpected(15 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(16 /* CloseBraceToken */); @@ -11895,13 +12209,13 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 46 /* BarToken */) { - var unionType = createNode(251 /* JSDocUnionType */, type.pos); + if (token === 47 /* BarToken */) { + var unionType = createNode(253 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 55 /* EqualsToken */) { - var optionalType = createNode(258 /* JSDocOptionalType */, type.pos); + if (token === 56 /* EqualsToken */) { + var optionalType = createNode(260 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -11912,20 +12226,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 19 /* OpenBracketToken */) { - var arrayType = createNode(250 /* JSDocArrayType */, type.pos); + var arrayType = createNode(252 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(20 /* CloseBracketToken */); type = finishNode(arrayType); } - else if (token === 52 /* QuestionToken */) { - var nullableType = createNode(253 /* JSDocNullableType */, type.pos); + else if (token === 53 /* QuestionToken */) { + var nullableType = createNode(255 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 48 /* ExclamationToken */) { - var nonNullableType = createNode(254 /* JSDocNonNullableType */, type.pos); + else if (token === 49 /* ExclamationToken */) { + var nonNullableType = createNode(256 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -11940,80 +12254,80 @@ var ts; switch (token) { case 37 /* AsteriskToken */: return parseJSDocAllType(); - case 52 /* QuestionToken */: + case 53 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); case 17 /* OpenParenToken */: return parseJSDocUnionType(); case 19 /* OpenBracketToken */: return parseJSDocTupleType(); - case 48 /* ExclamationToken */: + case 49 /* ExclamationToken */: return parseJSDocNonNullableType(); case 15 /* OpenBraceToken */: return parseJSDocRecordType(); - case 85 /* FunctionKeyword */: + case 87 /* FunctionKeyword */: return parseJSDocFunctionType(); case 22 /* DotDotDotToken */: return parseJSDocVariadicType(); - case 90 /* NewKeyword */: + case 92 /* NewKeyword */: return parseJSDocConstructorType(); - case 95 /* ThisKeyword */: + case 97 /* ThisKeyword */: return parseJSDocThisType(); - case 115 /* AnyKeyword */: - case 128 /* StringKeyword */: - case 126 /* NumberKeyword */: - case 118 /* BooleanKeyword */: - case 129 /* SymbolKeyword */: - case 101 /* VoidKeyword */: + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(262 /* JSDocThisType */); + var result = createNode(264 /* JSDocThisType */); nextToken(); - parseExpected(53 /* ColonToken */); + parseExpected(54 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(261 /* JSDocConstructorType */); + var result = createNode(263 /* JSDocConstructorType */); nextToken(); - parseExpected(53 /* ColonToken */); + parseExpected(54 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(260 /* JSDocVariadicType */); + var result = createNode(262 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(259 /* JSDocFunctionType */); + var result = createNode(261 /* JSDocFunctionType */); nextToken(); parseExpected(17 /* OpenParenToken */); result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(18 /* CloseParenToken */); - if (token === 53 /* ColonToken */) { + if (token === 54 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(136 /* Parameter */); + var parameter = createNode(138 /* Parameter */); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(258 /* JSDocOptionalType */, type.pos); + var result = createNode(260 /* JSDocOptionalType */, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(257 /* JSDocTypeReference */); + var result = createNode(259 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); while (parseOptional(21 /* DotToken */)) { if (token === 25 /* LessThanToken */) { @@ -12043,13 +12357,13 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(133 /* QualifiedName */, left.pos); + var result = createNode(135 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(255 /* JSDocRecordType */); + var result = createNode(257 /* JSDocRecordType */); nextToken(); result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember); checkForTrailingComma(result.members); @@ -12057,22 +12371,22 @@ var ts; return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(256 /* JSDocRecordMember */); + var result = createNode(258 /* JSDocRecordMember */); result.name = parseSimplePropertyName(); - if (token === 53 /* ColonToken */) { + if (token === 54 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(254 /* JSDocNonNullableType */); + var result = createNode(256 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(252 /* JSDocTupleType */); + var result = createNode(254 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); @@ -12086,7 +12400,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(251 /* JSDocUnionType */); + var result = createNode(253 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(18 /* CloseParenToken */); @@ -12097,14 +12411,14 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(46 /* BarToken */)) { + while (parseOptional(47 /* BarToken */)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(248 /* JSDocAllType */); + var result = createNode(250 /* JSDocAllType */); nextToken(); return finishNode(result); } @@ -12125,19 +12439,19 @@ var ts; token === 16 /* CloseBraceToken */ || token === 18 /* CloseParenToken */ || token === 27 /* GreaterThanToken */ || - token === 55 /* EqualsToken */ || - token === 46 /* BarToken */) { - var result = createNode(249 /* JSDocUnknownType */, pos); + token === 56 /* EqualsToken */ || + token === 47 /* BarToken */) { + var result = createNode(251 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(253 /* JSDocNullableType */, pos); + var result = createNode(255 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); + initializeState("file.js", content, 2 /* Latest */, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined); var jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length); var diagnostics = parseDiagnostics; clearState(); @@ -12219,7 +12533,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(263 /* JSDocComment */, start); + var result = createNode(265 /* JSDocComment */, start); result.tags = tags; return finishNode(result, end); } @@ -12230,7 +12544,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64 /* at */); - var atToken = createNode(54 /* AtToken */, pos - 1); + var atToken = createNode(55 /* AtToken */, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -12256,7 +12570,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(264 /* JSDocTag */, atToken.pos); + var result = createNode(266 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -12307,7 +12621,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(265 /* JSDocParameterTag */, atToken.pos); + var result = createNode(267 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -12317,27 +12631,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 266 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 268 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(266 /* JSDocReturnTag */, atToken.pos); + var result = createNode(268 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 267 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 269 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(267 /* JSDocTypeTag */, atToken.pos); + var result = createNode(269 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 268 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 270 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -12350,7 +12664,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(135 /* TypeParameter */, name_8.pos); + var typeParameter = createNode(137 /* TypeParameter */, name_8.pos); typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -12361,7 +12675,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(268 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(270 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -12382,7 +12696,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(67 /* Identifier */, startPos); + var result = createNode(69 /* Identifier */, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -12505,7 +12819,7 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 67 /* Identifier */: + case 69 /* Identifier */: return true; } return false; @@ -12898,17 +13212,19 @@ var ts; var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); var typeCount = 0; + var symbolCount = 0; var emptyArray = []; var emptySymbols = {}; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0 /* ES3 */; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */; var emitResolver = createResolver(); var undefinedSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "undefined"); var argumentsSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "arguments"); var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, - getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount"); }, + getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, getTypeCount: function () { return typeCount; }, isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, @@ -12999,6 +13315,7 @@ var ts; var getInstantiatedGlobalPromiseLikeType; var getGlobalPromiseConstructorLikeType; var getGlobalThenableType; + var cjsRequireType; var tupleTypes = {}; var unionTypes = {}; var intersectionTypes = {}; @@ -13069,6 +13386,7 @@ var ts; diagnostics.add(diagnostic); } function createSymbol(flags, name) { + symbolCount++; return new Symbol(flags, name); } function getExcludedSymbolFlags(flags) { @@ -13198,10 +13516,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 246 /* SourceFile */); + return ts.getAncestor(node, 248 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 246 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 248 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -13220,18 +13538,62 @@ var ts; } // return undefined if we can't find a symbol. } - /** Returns true if node1 is defined before node 2**/ - function isDefinedBefore(node1, node2) { - var file1 = ts.getSourceFileOfNode(node1); - var file2 = ts.getSourceFileOfNode(node2); - if (file1 === file2) { - return node1.pos <= node2.pos; + function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { + var declarationFile = ts.getSourceFileOfNode(declaration); + var useFile = ts.getSourceFileOfNode(usage); + if (declarationFile !== useFile) { + if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) { + // nodes are in different files and order cannot be determines + return true; + } + var sourceFiles = host.getSourceFiles(); + return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); + } + if (declaration.pos <= usage.pos) { + // declaration is before usage + // still might be illegal if usage is in the initializer of the variable declaration + return declaration.kind !== 211 /* VariableDeclaration */ || + !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + // declaration is after usage + // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) + return isUsedInFunctionOrNonStaticProperty(declaration, usage); + function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + if (declaration.parent.parent.kind === 193 /* VariableStatement */ || + declaration.parent.parent.kind === 199 /* ForStatement */) { + // variable statement/for statement case, + // use site should not be inside variable declaration (initializer of declaration or binding element) + return isSameScopeDescendentOf(usage, declaration, container); + } + else if (declaration.parent.parent.kind === 201 /* ForOfStatement */ || + declaration.parent.parent.kind === 200 /* ForInStatement */) { + // ForIn/ForOf case - use site should not be used in expression part + var expression = declaration.parent.parent.expression; + return isSameScopeDescendentOf(usage, expression, container); + } } - if (!compilerOptions.outFile && !compilerOptions.out) { - return true; + function isUsedInFunctionOrNonStaticProperty(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + var current = usage; + while (current) { + if (current === container) { + return false; + } + if (ts.isFunctionLike(current)) { + return true; + } + var initializerOfNonStaticProperty = current.parent && + current.parent.kind === 141 /* PropertyDeclaration */ && + (current.parent.flags & 128 /* Static */) === 0 && + current.parent.initializer === current; + if (initializerOfNonStaticProperty) { + return true; + } + current = current.parent; + } + return false; } - var sourceFiles = host.getSourceFiles(); - return sourceFiles.indexOf(file1) <= sourceFiles.indexOf(file2); } // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and // the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with @@ -13258,13 +13620,13 @@ var ts; } } switch (location.kind) { - case 246 /* SourceFile */: - if (!ts.isExternalModule(location)) + case 248 /* SourceFile */: + if (!ts.isExternalOrCommonJsModule(location)) break; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 246 /* SourceFile */ || - (location.kind === 216 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) { + if (location.kind === 248 /* SourceFile */ || + (location.kind === 218 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) { // It's an external module. Because of module/namespace merging, a module's exports are in scope, // yet we never want to treat an export specifier as putting a member in scope. Therefore, // if the name we find is purely an export specifier, it is not actually considered in scope. @@ -13278,7 +13640,7 @@ var ts; // which is not the desired behavior. if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 228 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 230 /* ExportSpecifier */)) { break; } result = moduleExports["default"]; @@ -13292,13 +13654,13 @@ var ts; break loop; } break; - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -13315,9 +13677,9 @@ var ts; } } break; - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 213 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -13328,7 +13690,7 @@ var ts; } break loop; } - if (location.kind === 184 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 186 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -13344,9 +13706,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 213 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 215 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -13354,19 +13716,19 @@ var ts; } } break; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: - case 172 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 171 /* FunctionExpression */: + case 173 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -13379,7 +13741,7 @@ var ts; } } break; - case 137 /* Decorator */: + case 139 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -13388,7 +13750,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 136 /* Parameter */) { + if (location.parent && location.parent.kind === 138 /* Parameter */) { location = location.parent; } // @@ -13434,8 +13796,11 @@ var ts; // block - scope variable and namespace module. However, only when we // try to resolve name in /*1*/ which is used in variable position, // we want to check for block- scoped - if (meaning & 2 /* BlockScopedVariable */ && result.flags & 2 /* BlockScopedVariable */) { - checkResolvedBlockScopedVariable(result, errorLocation); + if (meaning & 2 /* BlockScopedVariable */) { + var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); + if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */) { + checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); + } } } return result; @@ -13445,32 +13810,7 @@ var ts; // Block-scoped variables cannot be used before their definition var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - // first check if usage is lexically located after the declaration - var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); - if (!isUsedBeforeDeclaration) { - // lexical check succeeded however code still can be illegal. - // - block scoped variables cannot be used in its initializers - // let x = x; // illegal but usage is lexically after definition - // - in ForIn/ForOf statements variable cannot be contained in expression part - // for (let x in x) - // for (let x of x) - // climb up to the variable declaration skipping binding patterns - var variableDeclaration = ts.getAncestor(declaration, 209 /* VariableDeclaration */); - var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 191 /* VariableStatement */ || - variableDeclaration.parent.parent.kind === 197 /* ForStatement */) { - // variable statement/for statement case, - // use site should not be inside variable declaration (initializer of declaration or binding element) - isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); - } - else if (variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */ || - variableDeclaration.parent.parent.kind === 198 /* ForInStatement */) { - // ForIn/ForOf case - use site should not be used in expression part - var expression = variableDeclaration.parent.parent.expression; - isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); - } - } - if (isUsedBeforeDeclaration) { + if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 211 /* VariableDeclaration */), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -13491,10 +13831,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 219 /* ImportEqualsDeclaration */) { + if (node.kind === 221 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 220 /* ImportDeclaration */) { + while (node && node.kind !== 222 /* ImportDeclaration */) { node = node.parent; } return node; @@ -13504,7 +13844,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 230 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 232 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -13611,17 +13951,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 221 /* ImportClause */: + case 223 /* ImportClause */: return getTargetOfImportClause(node); - case 222 /* NamespaceImport */: + case 224 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 224 /* ImportSpecifier */: + case 226 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 228 /* ExportSpecifier */: + case 230 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -13666,11 +14006,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 225 /* ExportAssignment */) { + if (node.kind === 227 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 228 /* ExportSpecifier */) { + else if (node.kind === 230 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -13683,7 +14023,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 219 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 221 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -13692,17 +14032,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 67 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 69 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 67 /* Identifier */ || entityName.parent.kind === 133 /* QualifiedName */) { + if (entityName.kind === 69 /* Identifier */ || entityName.parent.kind === 135 /* QualifiedName */) { return resolveEntityName(entityName, 1536 /* Namespace */); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 219 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 221 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -13715,16 +14055,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 67 /* Identifier */) { + if (name.kind === 69 /* Identifier */) { var message = meaning === 1536 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 133 /* QualifiedName */ || name.kind === 164 /* PropertyAccessExpression */) { - var left = name.kind === 133 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 133 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 135 /* QualifiedName */ || name.kind === 166 /* PropertyAccessExpression */) { + var left = name.kind === 135 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 135 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -13743,11 +14083,6 @@ var ts; ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); return symbol.flags & meaning ? symbol : resolveAlias(symbol); } - function isExternalModuleNameRelative(moduleName) { - // TypeScript 1.0 spec (April 2014): 11.2.1 - // An external module name is "relative" if the first term is "." or "..". - return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; - } function resolveExternalModuleName(location, moduleReferenceExpression) { if (moduleReferenceExpression.kind !== 9 /* StringLiteral */) { return; @@ -13760,7 +14095,10 @@ var ts; if (moduleName === undefined) { return; } - var isRelative = isExternalModuleNameRelative(moduleName); + if (moduleName.indexOf("!") >= 0) { + moduleName = moduleName.substr(0, moduleName.indexOf("!")); + } + var isRelative = ts.isExternalModuleNameRelative(moduleName); if (!isRelative) { var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512 /* ValueModule */); if (symbol) { @@ -13876,7 +14214,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 142 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 144 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -13946,17 +14284,17 @@ var ts; } } switch (location_1.kind) { - case 246 /* SourceFile */: - if (!ts.isExternalModule(location_1)) { + case 248 /* SourceFile */: + if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -13997,7 +14335,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -14034,7 +14372,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -14107,8 +14445,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 216 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) || - (declaration.kind === 246 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 218 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) || + (declaration.kind === 248 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -14144,12 +14482,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 152 /* TypeQuery */) { + if (entityName.parent.kind === 154 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 133 /* QualifiedName */ || entityName.kind === 164 /* PropertyAccessExpression */ || - entityName.parent.kind === 219 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 135 /* QualifiedName */ || entityName.kind === 166 /* PropertyAccessExpression */ || + entityName.parent.kind === 221 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -14204,10 +14542,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 158 /* ParenthesizedType */) { + while (node.kind === 160 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 214 /* TypeAliasDeclaration */) { + if (node.kind === 216 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -14221,10 +14559,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 184 /* ClassExpression */: + case 186 /* ClassExpression */: return "(Anonymous class)"; - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -14307,6 +14645,7 @@ var ts; } function buildTypeDisplay(type, writer, enclosingDeclaration, globalFlags, symbolStack) { var globalFlagsToPass = globalFlags & 16 /* WriteOwnNameForAnyLike */; + var inObjectTypeLiteral = false; return writeType(type, globalFlags); function writeType(type, flags) { // Write undefined/null type as any @@ -14316,6 +14655,12 @@ var ts; ? "any" : type.intrinsicName); } + else if (type.flags & 33554432 /* ThisType */) { + if (inObjectTypeLiteral) { + writer.reportInaccessibleThisError(); + } + writer.writeKeyword("this"); + } else if (type.flags & 4096 /* Reference */) { writeTypeReference(type, flags); } @@ -14357,11 +14702,10 @@ var ts; writeType(types[i], delimiter === 24 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); } } - function writeSymbolTypeReference(symbol, typeArguments, pos, end) { - // Unnamed function expressions, arrow functions, and unnamed class expressions have reserved names that - // we don't want to display - if (!isReservedMemberName(symbol.name)) { - buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056 /* Type */); + function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { + // Unnamed function expressions and arrow functions have reserved names that we don't want to display + if (symbol.flags & 32 /* Class */ || !isReservedMemberName(symbol.name)) { + buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056 /* Type */, 0 /* None */, flags); } if (pos < end) { writePunctuation(writer, 25 /* LessThanToken */); @@ -14375,7 +14719,7 @@ var ts; } } function writeTypeReference(type, flags) { - var typeArguments = type.typeArguments; + var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { writeType(typeArguments[0], 64 /* InElementType */); writePunctuation(writer, 19 /* OpenBracketToken */); @@ -14399,12 +14743,13 @@ var ts; // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_3, typeArguments, start, i); + writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); writePunctuation(writer, 21 /* DotToken */); } } } - writeSymbolTypeReference(type.symbol, typeArguments, i, typeArguments.length); + var typeParameterCount = (type.target.typeParameters || emptyArray).length; + writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags); } } function writeTupleType(type) { @@ -14416,7 +14761,7 @@ var ts; if (flags & 64 /* InElementType */) { writePunctuation(writer, 17 /* OpenParenToken */); } - writeTypeList(type.types, type.flags & 16384 /* Union */ ? 46 /* BarToken */ : 45 /* AmpersandToken */); + writeTypeList(type.types, type.flags & 16384 /* Union */ ? 47 /* BarToken */ : 46 /* AmpersandToken */); if (flags & 64 /* InElementType */) { writePunctuation(writer, 18 /* CloseParenToken */); } @@ -14440,7 +14785,7 @@ var ts; } else { // Recursive usage, use any - writeKeyword(writer, 115 /* AnyKeyword */); + writeKeyword(writer, 117 /* AnyKeyword */); } } else { @@ -14464,7 +14809,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 246 /* SourceFile */ || declaration.parent.kind === 217 /* ModuleBlock */; + return declaration.parent.kind === 248 /* SourceFile */ || declaration.parent.kind === 219 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -14474,7 +14819,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 99 /* TypeOfKeyword */); + writeKeyword(writer, 101 /* TypeOfKeyword */); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } @@ -14510,7 +14855,7 @@ var ts; if (flags & 64 /* InElementType */) { writePunctuation(writer, 17 /* OpenParenToken */); } - writeKeyword(writer, 90 /* NewKeyword */); + writeKeyword(writer, 92 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); if (flags & 64 /* InElementType */) { @@ -14519,6 +14864,8 @@ var ts; return; } } + var saveInObjectTypeLiteral = inObjectTypeLiteral; + inObjectTypeLiteral = true; writePunctuation(writer, 15 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); @@ -14530,7 +14877,7 @@ var ts; } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 90 /* NewKeyword */); + writeKeyword(writer, 92 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 23 /* SemicolonToken */); @@ -14540,11 +14887,11 @@ var ts; // [x: string]: writePunctuation(writer, 19 /* OpenBracketToken */); writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, /*fallbackName*/ "x")); - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 128 /* StringKeyword */); + writeKeyword(writer, 130 /* StringKeyword */); writePunctuation(writer, 20 /* CloseBracketToken */); - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); writeType(resolved.stringIndexType, 0 /* None */); writePunctuation(writer, 23 /* SemicolonToken */); @@ -14554,11 +14901,11 @@ var ts; // [x: number]: writePunctuation(writer, 19 /* OpenBracketToken */); writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, /*fallbackName*/ "x")); - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 126 /* NumberKeyword */); + writeKeyword(writer, 128 /* NumberKeyword */); writePunctuation(writer, 20 /* CloseBracketToken */); - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); writeType(resolved.numberIndexType, 0 /* None */); writePunctuation(writer, 23 /* SemicolonToken */); @@ -14573,7 +14920,7 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 52 /* QuestionToken */); + writePunctuation(writer, 53 /* QuestionToken */); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 23 /* SemicolonToken */); @@ -14583,9 +14930,9 @@ var ts; else { buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 52 /* QuestionToken */); + writePunctuation(writer, 53 /* QuestionToken */); } - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); writePunctuation(writer, 23 /* SemicolonToken */); @@ -14594,6 +14941,7 @@ var ts; } writer.decreaseIndent(); writePunctuation(writer, 16 /* CloseBraceToken */); + inObjectTypeLiteral = saveInObjectTypeLiteral; } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { @@ -14607,7 +14955,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 81 /* ExtendsKeyword */); + writeKeyword(writer, 83 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -14619,9 +14967,9 @@ var ts; } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 52 /* QuestionToken */); + writePunctuation(writer, 53 /* QuestionToken */); } - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } @@ -14668,14 +15016,14 @@ var ts; writePunctuation(writer, 34 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 122 /* IsKeyword */); + writeKeyword(writer, 124 /* IsKeyword */); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -14711,13 +15059,13 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 216 /* ModuleDeclaration */) { + if (node.kind === 218 /* ModuleDeclaration */) { if (node.name.kind === 9 /* StringLiteral */) { return node; } } - else if (node.kind === 246 /* SourceFile */) { - return ts.isExternalModule(node) ? node : undefined; + else if (node.kind === 248 /* SourceFile */) { + return ts.isExternalOrCommonJsModule(node) ? node : undefined; } } ts.Debug.fail("getContainingModule cant reach here"); @@ -14765,70 +15113,70 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 161 /* BindingElement */: + case 163 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 209 /* VariableDeclaration */: + case 211 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // Otherwise fall through - case 216 /* ModuleDeclaration */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 211 /* FunctionDeclaration */: - case 215 /* EnumDeclaration */: - case 219 /* ImportEqualsDeclaration */: + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 213 /* FunctionDeclaration */: + case 217 /* EnumDeclaration */: + case 221 /* ImportEqualsDeclaration */: var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && - !(node.kind !== 219 /* ImportEqualsDeclaration */ && parent_4.kind !== 246 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 221 /* ImportEqualsDeclaration */ && parent_4.kind !== 248 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_4); - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so let it fall into next case statement - case 142 /* Constructor */: - case 146 /* ConstructSignature */: - case 145 /* CallSignature */: - case 147 /* IndexSignature */: - case 136 /* Parameter */: - case 217 /* ModuleBlock */: - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 153 /* TypeLiteral */: - case 149 /* TypeReference */: - case 154 /* ArrayType */: - case 155 /* TupleType */: - case 156 /* UnionType */: - case 157 /* IntersectionType */: - case 158 /* ParenthesizedType */: + case 144 /* Constructor */: + case 148 /* ConstructSignature */: + case 147 /* CallSignature */: + case 149 /* IndexSignature */: + case 138 /* Parameter */: + case 219 /* ModuleBlock */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 155 /* TypeLiteral */: + case 151 /* TypeReference */: + case 156 /* ArrayType */: + case 157 /* TupleType */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: + case 160 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 221 /* ImportClause */: - case 222 /* NamespaceImport */: - case 224 /* ImportSpecifier */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: + case 226 /* ImportSpecifier */: return false; // Type parameters are always visible - case 135 /* TypeParameter */: + case 137 /* TypeParameter */: // Source file is always visible - case 246 /* SourceFile */: + case 248 /* SourceFile */: return true; - // Export assignements do not create name bindings outside the module - case 225 /* ExportAssignment */: + // Export assignments do not create name bindings outside the module + case 227 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -14844,10 +15192,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 225 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 227 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 228 /* ExportSpecifier */) { + else if (node.parent.kind === 230 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -14939,7 +15287,7 @@ var ts; node = ts.getRootDeclaration(node); // Parent chain: // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 209 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + return node.kind === 211 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -14957,10 +15305,16 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1 /* Any */) !== 0; } + // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been + // assigned by contextual typing. + function getTypeForBindingElementParent(node) { + var symbol = getSymbolOfNode(node); + return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node); + } // Return the inferred type for a binding element function getTypeForBindingElement(declaration) { var pattern = declaration.parent; - var parentType = getTypeForVariableLikeDeclaration(pattern.parent); + var parentType = getTypeForBindingElementParent(pattern.parent); // If parent has the unknown (error) type, then so does this binding element if (parentType === unknownType) { return unknownType; @@ -14975,7 +15329,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 159 /* ObjectBindingPattern */) { + if (pattern.kind === 161 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_10 = declaration.propertyName || declaration.name; // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, @@ -15019,10 +15373,10 @@ var ts; // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration) { // A variable declared in a for..in statement is always of type any - if (declaration.parent.parent.kind === 198 /* ForInStatement */) { + if (declaration.parent.parent.kind === 200 /* ForInStatement */) { return anyType; } - if (declaration.parent.parent.kind === 199 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 201 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -15036,11 +15390,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 136 /* Parameter */) { + if (declaration.kind === 138 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 144 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143 /* GetAccessor */); + if (func.kind === 146 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -15056,7 +15410,7 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 244 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 246 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -15102,7 +15456,7 @@ var ts; return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType; } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. - var elementTypes = ts.map(elements, function (e) { return e.kind === 185 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + var elementTypes = ts.map(elements, function (e) { return e.kind === 187 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); if (includePatternInType) { var result = createNewTupleType(elementTypes); result.pattern = pattern; @@ -15118,7 +15472,7 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern, includePatternInType) { - return pattern.kind === 159 /* ObjectBindingPattern */ + return pattern.kind === 161 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType) : getTypeFromArrayBindingPattern(pattern, includePatternInType); } @@ -15140,14 +15494,14 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - return declaration.kind !== 243 /* PropertyAssignment */ ? getWidenedType(type) : type; + return declaration.kind !== 245 /* PropertyAssignment */ ? getWidenedType(type) : type; } // Rest parameters default to type any[], other parameters default to type any type = declaration.dotDotDotToken ? anyArrayType : anyType; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 136 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 138 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -15162,13 +15516,21 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 242 /* CatchClause */) { + if (declaration.parent.kind === 244 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 225 /* ExportAssignment */) { + if (declaration.kind === 227 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } + // Handle module.exports = expr + if (declaration.kind === 181 /* BinaryExpression */) { + return links.type = checkExpression(declaration.right); + } + // Handle exports.p = expr + if (declaration.kind === 166 /* PropertyAccessExpression */) { + return checkExpressionCached(declaration.parent.right); + } // Handle variable, parameter or property if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; @@ -15194,7 +15556,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 143 /* GetAccessor */) { + if (accessor.kind === 145 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -15210,8 +15572,8 @@ var ts; if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 143 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 144 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 146 /* SetAccessor */); var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); @@ -15240,7 +15602,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 143 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */); error(getter_1, 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)); } } @@ -15340,9 +15702,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */ || - node.kind === 211 /* FunctionDeclaration */ || node.kind === 171 /* FunctionExpression */ || - node.kind === 141 /* MethodDeclaration */ || node.kind === 172 /* ArrowFunction */) { + if (node.kind === 214 /* ClassDeclaration */ || node.kind === 186 /* ClassExpression */ || + node.kind === 213 /* FunctionDeclaration */ || node.kind === 173 /* FunctionExpression */ || + node.kind === 143 /* MethodDeclaration */ || node.kind === 174 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -15352,7 +15714,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 215 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -15361,8 +15723,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 212 /* ClassDeclaration */ || - node.kind === 184 /* ClassExpression */ || node.kind === 214 /* TypeAliasDeclaration */) { + if (node.kind === 215 /* InterfaceDeclaration */ || node.kind === 214 /* ClassDeclaration */ || + node.kind === 186 /* ClassExpression */ || node.kind === 216 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -15482,7 +15844,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 213 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 215 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -15503,6 +15865,32 @@ var ts; } } } + // Returns true if the interface given by the symbol is free of "this" references. Specifically, the result is + // true if the interface itself contains no references to "this" in its body, if all base types are interfaces, + // and if none of the base interfaces have a "this" type. + function isIndependentInterface(symbol) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 215 /* InterfaceDeclaration */) { + if (declaration.flags & 524288 /* ContainsThis */) { + return false; + } + var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); + if (baseTypeNodes) { + for (var _b = 0; _b < baseTypeNodes.length; _b++) { + var node = baseTypeNodes[_b]; + if (ts.isSupportedExpressionWithTypeArguments(node)) { + var baseSymbol = resolveEntityName(node.expression, 793056 /* Type */, /*ignoreErrors*/ true); + if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + return false; + } + } + } + } + } + } + return true; + } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { @@ -15510,7 +15898,12 @@ var ts; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - if (outerTypeParameters || localTypeParameters) { + // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type + // because it is not feasible to analyze all members to determine if the "this" type escapes the class (in particular, + // property types inferred from initializers and method return types inferred from return statements are very hard + // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of + // "this" references. + if (outerTypeParameters || localTypeParameters || kind === 1024 /* Class */ || !isIndependentInterface(symbol)) { type.flags |= 4096 /* Reference */; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; @@ -15519,6 +15912,9 @@ var ts; type.instantiations[getTypeListId(type.typeParameters)] = type; type.target = type; type.typeArguments = type.typeParameters; + type.thisType = createType(512 /* TypeParameter */ | 33554432 /* ThisType */); + type.thisType.symbol = symbol; + type.thisType.constraint = getTypeWithThisArgument(type); } } return links.declaredType; @@ -15531,7 +15927,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 214 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 216 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -15564,7 +15960,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -15597,6 +15993,79 @@ var ts; } return unknownType; } + // A type reference is considered independent if each type argument is considered independent. + function isIndependentTypeReference(node) { + if (node.typeArguments) { + for (var _i = 0, _a = node.typeArguments; _i < _a.length; _i++) { + var typeNode = _a[_i]; + if (!isIndependentType(typeNode)) { + return false; + } + } + } + return true; + } + // A type is considered independent if it the any, string, number, boolean, symbol, or void keyword, a string + // literal type, an array with an element type that is considered independent, or a type reference that is + // considered independent. + function isIndependentType(node) { + switch (node.kind) { + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: + case 9 /* StringLiteral */: + return true; + case 156 /* ArrayType */: + return isIndependentType(node.elementType); + case 151 /* TypeReference */: + return isIndependentTypeReference(node); + } + return false; + } + // A variable-like declaration is considered independent (free of this references) if it has a type annotation + // that specifies an independent type, or if it has no type annotation and no initializer (and thus of type any). + function isIndependentVariableLikeDeclaration(node) { + return node.type && isIndependentType(node.type) || !node.type && !node.initializer; + } + // A function-like declaration is considered independent (free of this references) if it has a return type + // annotation that is considered independent and if each parameter is considered independent. + function isIndependentFunctionLikeDeclaration(node) { + if (node.kind !== 144 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + return false; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + if (!isIndependentVariableLikeDeclaration(parameter)) { + return false; + } + } + return true; + } + // Returns true if the class or interface member given by the symbol is free of "this" references. The + // function may return false for symbols that are actually free of "this" references because it is not + // feasible to perform a complete analysis in all cases. In particular, property members with types + // inferred from their initializers and function members with inferred return types are convervatively + // assumed not to be free of "this" references. + function isIndependentMember(symbol) { + if (symbol.declarations && symbol.declarations.length === 1) { + var declaration = symbol.declarations[0]; + if (declaration) { + switch (declaration.kind) { + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return isIndependentVariableLikeDeclaration(declaration); + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + return isIndependentFunctionLikeDeclaration(declaration); + } + } + } + return false; + } function createSymbolTable(symbols) { var result = {}; for (var _i = 0; _i < symbols.length; _i++) { @@ -15605,11 +16074,13 @@ var ts; } return result; } - function createInstantiatedSymbolTable(symbols, mapper) { + // The mappingThisOnly flag indicates that the only type parameter being mapped is "this". When the flag is true, + // we check symbols to see if we can quickly conclude they are free of "this" references, thus needing no instantiation. + function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { var result = {}; for (var _i = 0; _i < symbols.length; _i++) { var symbol = symbols[_i]; - result[symbol.name] = instantiateSymbol(symbol, mapper); + result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } return result; } @@ -15640,44 +16111,54 @@ var ts; } return type; } - function resolveClassOrInterfaceMembers(type) { - var target = resolveDeclaredMembers(type); - var members = target.symbol.members; - var callSignatures = target.declaredCallSignatures; - var constructSignatures = target.declaredConstructSignatures; - var stringIndexType = target.declaredStringIndexType; - var numberIndexType = target.declaredNumberIndexType; - var baseTypes = getBaseTypes(target); + function getTypeWithThisArgument(type, thisArgument) { + if (type.flags & 4096 /* Reference */) { + return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + } + return type; + } + function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) { + var mapper = identityMapper; + var members = source.symbol.members; + var callSignatures = source.declaredCallSignatures; + var constructSignatures = source.declaredConstructSignatures; + var stringIndexType = source.declaredStringIndexType; + var numberIndexType = source.declaredNumberIndexType; + if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { + mapper = createTypeMapper(typeParameters, typeArguments); + members = createInstantiatedSymbolTable(source.declaredProperties, mapper, /*mappingThisOnly*/ typeParameters.length === 1); + callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); + constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); + stringIndexType = instantiateType(source.declaredStringIndexType, mapper); + numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); + } + var baseTypes = getBaseTypes(source); if (baseTypes.length) { - members = createSymbolTable(target.declaredProperties); + if (members === source.symbol.members) { + members = createSymbolTable(source.declaredProperties); + } + var thisArgument = ts.lastOrUndefined(typeArguments); for (var _i = 0; _i < baseTypes.length; _i++) { var baseType = baseTypes[_i]; - addInheritedMembers(members, getPropertiesOfObjectType(baseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(baseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(baseType, 1 /* Construct */)); - stringIndexType = stringIndexType || getIndexTypeOfType(baseType, 0 /* String */); - numberIndexType = numberIndexType || getIndexTypeOfType(baseType, 1 /* Number */); + var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; + addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); + stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0 /* String */); + numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1 /* Number */); } } setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } + function resolveClassOrInterfaceMembers(type) { + resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); + } function resolveTypeReferenceMembers(type) { - var target = resolveDeclaredMembers(type.target); - var mapper = createTypeMapper(target.typeParameters, type.typeArguments); - var members = createInstantiatedSymbolTable(target.declaredProperties, mapper); - var callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); - var constructSignatures = instantiateList(target.declaredConstructSignatures, mapper, instantiateSignature); - var stringIndexType = target.declaredStringIndexType ? instantiateType(target.declaredStringIndexType, mapper) : undefined; - var numberIndexType = target.declaredNumberIndexType ? instantiateType(target.declaredNumberIndexType, mapper) : undefined; - ts.forEach(getBaseTypes(target), function (baseType) { - var instantiatedBaseType = instantiateType(baseType, mapper); - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0 /* String */); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1 /* Number */); - }); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var source = resolveDeclaredMembers(type.target); + var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); + var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? + type.typeArguments : ts.concatenate(type.typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); @@ -15726,7 +16207,9 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noSubtypeReduction*/ true))); + var arrayElementType = getUnionType(type.elementTypes, /*noSubtypeReduction*/ true); + // Make the tuple type itself the 'this' type by including an extra type argument + var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -15842,7 +16325,14 @@ var ts; var constructSignatures; var stringIndexType; var numberIndexType; - if (symbol.flags & 2048 /* TypeLiteral */) { + if (type.target) { + members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); + callSignatures = instantiateList(getSignaturesOfType(type.target, 0 /* Call */), type.mapper, instantiateSignature); + constructSignatures = instantiateList(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper, instantiateSignature); + stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0 /* String */), type.mapper); + numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1 /* Number */), type.mapper); + } + else if (symbol.flags & 2048 /* TypeLiteral */) { members = symbol.members; callSignatures = getSignaturesOfSymbol(members["__call"]); constructSignatures = getSignaturesOfSymbol(members["__new"]); @@ -15879,7 +16369,10 @@ var ts; } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & (1024 /* Class */ | 2048 /* Interface */)) { + if (type.flags & 4096 /* Reference */) { + resolveTypeReferenceMembers(type); + } + else if (type.flags & (1024 /* Class */ | 2048 /* Interface */)) { resolveClassOrInterfaceMembers(type); } else if (type.flags & 65536 /* Anonymous */) { @@ -15894,9 +16387,6 @@ var ts; else if (type.flags & 32768 /* Intersection */) { resolveIntersectionTypeMembers(type); } - else { - resolveTypeReferenceMembers(type); - } } return type; } @@ -16125,7 +16615,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 142 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 144 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -16157,7 +16647,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 148 /* TypePredicate */) { + if (declaration.type.kind === 150 /* TypePredicate */) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -16169,8 +16659,8 @@ var ts; else { // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 143 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 144 /* SetAccessor */); + if (declaration.kind === 145 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 146 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -16188,19 +16678,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -16215,6 +16705,16 @@ var ts; } return result; } + function resolveExternalModuleTypeByLiteral(name) { + var moduleSym = resolveExternalModuleName(name, name); + if (moduleSym) { + var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); + if (resolvedModuleSymbol) { + return getTypeOfSymbol(resolvedModuleSymbol); + } + } + return anyType; + } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { @@ -16277,7 +16777,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 142 /* Constructor */ || signature.declaration.kind === 146 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 144 /* Constructor */ || signature.declaration.kind === 148 /* ConstructSignature */; var type = createObjectType(65536 /* Anonymous */ | 262144 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -16291,7 +16791,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 126 /* NumberKeyword */ : 128 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 128 /* NumberKeyword */ : 130 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -16320,30 +16820,33 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 137 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137 /* TypeParameter */).parent); } function getTypeListId(types) { - switch (types.length) { - case 1: - return "" + types[0].id; - case 2: - return types[0].id + "," + types[1].id; - default: - var result = ""; - for (var i = 0; i < types.length; i++) { - if (i > 0) { - result += ","; + if (types) { + switch (types.length) { + case 1: + return "" + types[0].id; + case 2: + return types[0].id + "," + types[1].id; + default: + var result = ""; + for (var i = 0; i < types.length; i++) { + if (i > 0) { + result += ","; + } + result += types[i].id; } - result += types[i].id; - } - return result; + return result; + } } + return ""; } // This function is used to propagate certain flags when creating new object type references and union types. // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type @@ -16361,7 +16864,7 @@ var ts; var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 /* Reference */ | getPropagatingFlagsOfTypes(typeArguments); + var flags = 4096 /* Reference */ | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -16380,13 +16883,13 @@ var ts; currentNode = currentNode.parent; } // if last step was made from the type parameter this means that path has started somewhere in constraint which is illegal - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 137 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 149 /* TypeReference */ && n.typeName.kind === 67 /* Identifier */) { + if (n.kind === 151 /* TypeReference */ && n.typeName.kind === 69 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -16473,7 +16976,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 149 /* TypeReference */ ? node.typeName : + var typeNameOrExpression = node.kind === 151 /* TypeReference */ ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; @@ -16505,9 +17008,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: return declaration; } } @@ -16548,10 +17051,13 @@ var ts; * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type */ function getExportedTypeFromNamespace(namespace, name) { - var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); - var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 /* Type */); + var typeSymbol = getExportedSymbolFromNamespace(namespace, name); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } + function getExportedSymbolFromNamespace(namespace, name) { + var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); + return namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 /* Type */ | 107455 /* Value */); + } function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } @@ -16567,17 +17073,17 @@ var ts; /** * Instantiates a global type that is generic with some element type, and returns that instantiation. */ - function createTypeFromGenericGlobalType(genericGlobalType, elementType) { - return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, [elementType]) : emptyObjectType; + function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { + return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; } function createIterableType(elementType) { - return createTypeFromGenericGlobalType(globalIterableType, elementType); + return createTypeFromGenericGlobalType(globalIterableType, [elementType]); } function createIterableIteratorType(elementType) { - return createTypeFromGenericGlobalType(globalIterableIteratorType, elementType); + return createTypeFromGenericGlobalType(globalIterableIteratorType, [elementType]); } function createArrayType(elementType) { - return createTypeFromGenericGlobalType(globalArrayType, elementType); + return createTypeFromGenericGlobalType(globalArrayType, [elementType]); } function getTypeFromArrayTypeNode(node) { var links = getNodeLinks(node); @@ -16749,48 +17255,68 @@ var ts; } return links.resolvedType; } + function getThisType(node) { + var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); + var parent = container && container.parent; + if (parent && (ts.isClassLike(parent) || parent.kind === 215 /* InterfaceDeclaration */)) { + if (!(container.flags & 128 /* Static */)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; + } + } + error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); + return unknownType; + } + function getTypeFromThisTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getThisType(node); + } + return links.resolvedType; + } function getTypeFromTypeNode(node) { switch (node.kind) { - case 115 /* AnyKeyword */: + case 117 /* AnyKeyword */: return anyType; - case 128 /* StringKeyword */: + case 130 /* StringKeyword */: return stringType; - case 126 /* NumberKeyword */: + case 128 /* NumberKeyword */: return numberType; - case 118 /* BooleanKeyword */: + case 120 /* BooleanKeyword */: return booleanType; - case 129 /* SymbolKeyword */: + case 131 /* SymbolKeyword */: return esSymbolType; - case 101 /* VoidKeyword */: + case 103 /* VoidKeyword */: return voidType; + case 97 /* ThisKeyword */: + return getTypeFromThisTypeNode(node); case 9 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 149 /* TypeReference */: + case 151 /* TypeReference */: return getTypeFromTypeReference(node); - case 148 /* TypePredicate */: + case 150 /* TypePredicate */: return booleanType; - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 154 /* ArrayType */: + case 156 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 155 /* TupleType */: + case 157 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 156 /* UnionType */: + case 158 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 157 /* IntersectionType */: + case 159 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 158 /* ParenthesizedType */: + case 160 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 153 /* TypeLiteral */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 155 /* TypeLiteral */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 67 /* Identifier */: - case 133 /* QualifiedName */: + case 69 /* Identifier */: + case 135 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -16894,7 +17420,7 @@ var ts; type: instantiateType(signature.typePredicate.type, mapper) }; } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -16932,21 +17458,13 @@ var ts; } // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it var result = createObjectType(65536 /* Anonymous */ | 131072 /* Instantiated */, type.symbol); - result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); - result.members = createSymbolTable(result.properties); - result.callSignatures = instantiateList(getSignaturesOfType(type, 0 /* Call */), mapper, instantiateSignature); - result.constructSignatures = instantiateList(getSignaturesOfType(type, 1 /* Construct */), mapper, instantiateSignature); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType) - result.stringIndexType = instantiateType(stringIndexType, mapper); - if (numberIndexType) - result.numberIndexType = instantiateType(numberIndexType, mapper); + result.target = type; + result.mapper = mapper; mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { - if (mapper !== identityMapper) { + if (type && mapper !== identityMapper) { if (type.flags & 512 /* TypeParameter */) { return mapper(type); } @@ -16972,27 +17490,27 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 179 /* BinaryExpression */: - return node.operatorToken.kind === 51 /* BarBarToken */ && + case 181 /* BinaryExpression */: + return node.operatorToken.kind === 52 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 243 /* PropertyAssignment */: + case 245 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -17176,7 +17694,7 @@ var ts; else { if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { // We have type references to same target type, see if relationship holds for all type arguments - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { return result; } } @@ -17205,7 +17723,7 @@ var ts; if (source.flags & 80896 /* ObjectType */ && target.flags & 80896 /* ObjectType */) { if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { // We have type references to same target type, see if all type arguments are identical - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, /*reportErrors*/ false)) { + if (result = typeArgumentsRelatedTo(source, target, /*reportErrors*/ false)) { return result; } } @@ -17322,9 +17840,14 @@ var ts; } return result; } - function typesRelatedTo(sources, targets, reportErrors) { + function typeArgumentsRelatedTo(source, target, reportErrors) { + var sources = source.typeArguments || emptyArray; + var targets = target.typeArguments || emptyArray; + if (sources.length !== targets.length && relation === identityRelation) { + return 0 /* False */; + } var result = -1 /* True */; - for (var i = 0, len = sources.length; i < len; i++) { + for (var i = 0; i < targets.length; i++) { var related = isRelatedTo(sources[i], targets[i], reportErrors); if (!related) { return 0 /* False */; @@ -17542,7 +18065,7 @@ var ts; if (kind === 1 /* Construct */) { // Only want to compare the construct signatures for abstractness guarantees. // Because the "abstractness" of a class is the same across all construct signatures - // (internally we are checking the corresponding declaration), it is enough to perform + // (internally we are checking the corresponding declaration), it is enough to perform // the check and report an error once over all pairs of source and target construct signatures. // // sourceSig and targetSig are (possibly) undefined. @@ -18042,22 +18565,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 136 /* Parameter */: + case 138 /* Parameter */: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -18167,9 +18690,10 @@ var ts; } else if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { // If source and target are references to the same generic type, infer from type arguments - var sourceTypes = source.typeArguments; - var targetTypes = target.typeArguments; - for (var i = 0; i < sourceTypes.length; i++) { + var sourceTypes = source.typeArguments || emptyArray; + var targetTypes = target.typeArguments || emptyArray; + var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; + for (var i = 0; i < count; i++) { inferFromTypes(sourceTypes[i], targetTypes[i]); } } @@ -18347,10 +18871,10 @@ var ts; // The expression is restricted to a single identifier or a sequence of identifiers separated by periods while (node) { switch (node.kind) { - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return true; - case 67 /* Identifier */: - case 133 /* QualifiedName */: + case 69 /* Identifier */: + case 135 /* QualifiedName */: node = node.parent; continue; default: @@ -18396,12 +18920,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 55 /* FirstAssignment */ && node.operatorToken.kind <= 66 /* LastAssignment */) { + if (node.operatorToken.kind >= 56 /* FirstAssignment */ && node.operatorToken.kind <= 68 /* LastAssignment */) { var n = node.left; - while (n.kind === 170 /* ParenthesizedExpression */) { + while (n.kind === 172 /* ParenthesizedExpression */) { n = n.expression; } - if (n.kind === 67 /* Identifier */ && getResolvedSymbol(n) === symbol) { + if (n.kind === 69 /* Identifier */ && getResolvedSymbol(n) === symbol) { return true; } } @@ -18415,55 +18939,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 159 /* ObjectBindingPattern */: - case 160 /* ArrayBindingPattern */: - case 162 /* ArrayLiteralExpression */: - case 163 /* ObjectLiteralExpression */: - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 169 /* TypeAssertionExpression */: - case 187 /* AsExpression */: - case 170 /* ParenthesizedExpression */: - case 177 /* PrefixUnaryExpression */: - case 173 /* DeleteExpression */: - case 176 /* AwaitExpression */: - case 174 /* TypeOfExpression */: - case 175 /* VoidExpression */: - case 178 /* PostfixUnaryExpression */: - case 182 /* YieldExpression */: - case 180 /* ConditionalExpression */: - case 183 /* SpreadElementExpression */: - case 190 /* Block */: - case 191 /* VariableStatement */: - case 193 /* ExpressionStatement */: - case 194 /* IfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 202 /* ReturnStatement */: - case 203 /* WithStatement */: - case 204 /* SwitchStatement */: - case 239 /* CaseClause */: - case 240 /* DefaultClause */: - case 205 /* LabeledStatement */: - case 206 /* ThrowStatement */: - case 207 /* TryStatement */: - case 242 /* CatchClause */: - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - case 236 /* JsxAttribute */: - case 237 /* JsxSpreadAttribute */: - case 233 /* JsxOpeningElement */: - case 238 /* JsxExpression */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + case 164 /* ArrayLiteralExpression */: + case 165 /* ObjectLiteralExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: + case 172 /* ParenthesizedExpression */: + case 179 /* PrefixUnaryExpression */: + case 175 /* DeleteExpression */: + case 178 /* AwaitExpression */: + case 176 /* TypeOfExpression */: + case 177 /* VoidExpression */: + case 180 /* PostfixUnaryExpression */: + case 184 /* YieldExpression */: + case 182 /* ConditionalExpression */: + case 185 /* SpreadElementExpression */: + case 192 /* Block */: + case 193 /* VariableStatement */: + case 195 /* ExpressionStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 204 /* ReturnStatement */: + case 205 /* WithStatement */: + case 206 /* SwitchStatement */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + case 207 /* LabeledStatement */: + case 208 /* ThrowStatement */: + case 209 /* TryStatement */: + case 244 /* CatchClause */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 238 /* JsxAttribute */: + case 239 /* JsxSpreadAttribute */: + case 235 /* JsxOpeningElement */: + case 240 /* JsxExpression */: return ts.forEachChild(node, isAssignedIn); } return false; @@ -18480,37 +19004,37 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 194 /* IfStatement */: + case 196 /* IfStatement */: // In a branch of an if statement, narrow based on controlling expression if (child !== node.expression) { narrowedType = narrowType(type, node.expression, /*assumeTrue*/ child === node.thenStatement); } break; - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: // In a branch of a conditional expression, narrow based on controlling condition if (child !== node.condition) { narrowedType = narrowType(type, node.condition, /*assumeTrue*/ child === node.whenTrue); } break; - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node.right) { - if (node.operatorToken.kind === 50 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 51 /* AmpersandAmpersandToken */) { narrowedType = narrowType(type, node.left, /*assumeTrue*/ true); } - else if (node.operatorToken.kind === 51 /* BarBarToken */) { + else if (node.operatorToken.kind === 52 /* BarBarToken */) { narrowedType = narrowType(type, node.left, /*assumeTrue*/ false); } } break; - case 246 /* SourceFile */: - case 216 /* ModuleDeclaration */: - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 142 /* Constructor */: + case 248 /* SourceFile */: + case 218 /* ModuleDeclaration */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: // Stop at the first containing function or module declaration break loop; } @@ -18527,12 +19051,12 @@ var ts; return type; function narrowTypeByEquality(type, expr, assumeTrue) { // Check that we have 'typeof ' on the left and string literal on the right - if (expr.left.kind !== 174 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { + if (expr.left.kind !== 176 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 67 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 69 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; @@ -18592,7 +19116,7 @@ var ts; } function narrowTypeByInstanceof(type, expr, assumeTrue) { // Check that type is not any, assumed result is true, and we have variable symbol on the left - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 69 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { return type; } // Check that right operand is a function type with a prototype property @@ -18664,27 +19188,27 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 166 /* CallExpression */: + case 168 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: var operator = expr.operatorToken.kind; if (operator === 32 /* EqualsEqualsEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 50 /* AmpersandAmpersandToken */) { + else if (operator === 51 /* AmpersandAmpersandToken */) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 51 /* BarBarToken */) { + else if (operator === 52 /* BarBarToken */) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 89 /* InstanceOfKeyword */) { + else if (operator === 91 /* InstanceOfKeyword */) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 177 /* PrefixUnaryExpression */: - if (expr.operator === 48 /* ExclamationToken */) { + case 179 /* PrefixUnaryExpression */: + if (expr.operator === 49 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -18702,7 +19226,7 @@ var ts; // can explicitly bound arguments objects if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 172 /* ArrowFunction */) { + if (container.kind === 174 /* ArrowFunction */) { if (languageVersion < 2 /* ES6 */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -18733,7 +19257,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & 2 /* BlockScopedVariable */) === 0 || - symbol.valueDeclaration.parent.kind === 242 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 244 /* CatchClause */) { return; } // - check if binding is used in some function @@ -18742,12 +19266,12 @@ var ts; // nesting structure: // (variable declaration or binding element) -> variable declaration list -> container var container = symbol.valueDeclaration; - while (container.kind !== 210 /* VariableDeclarationList */) { + while (container.kind !== 212 /* VariableDeclarationList */) { container = container.parent; } // get the parent of variable declaration list container = container.parent; - if (container.kind === 191 /* VariableStatement */) { + if (container.kind === 193 /* VariableStatement */) { // if parent is variable statement - get its parent container = container.parent; } @@ -18767,7 +19291,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 139 /* PropertyDeclaration */ || container.kind === 142 /* Constructor */) { + if (container.kind === 141 /* PropertyDeclaration */ || container.kind === 144 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -18781,32 +19305,32 @@ var ts; var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 172 /* ArrowFunction */) { + if (container.kind === 174 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); } switch (container.kind) { - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 142 /* Constructor */: + case 144 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -18815,35 +19339,35 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); + return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } return anyType; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 136 /* Parameter */) { + if (n.kind === 138 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 168 /* CallExpression */ && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; var container = ts.getSuperContainer(node, /*includeFunctions*/ true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting - while (container && container.kind === 172 /* ArrowFunction */) { + // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting + while (container && container.kind === 174 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*includeFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; } } var canUseSuperExpression = isLegalUsageOfSuperExpression(container); var nodeCheckFlag = 0; - // always set NodeCheckFlags for 'super' expression node + // always set NodeCheckFlags for 'super' expression node if (canUseSuperExpression) { if ((container.flags & 128 /* Static */) || isCallExpression) { nodeCheckFlag = 512 /* SuperStatic */; @@ -18866,7 +19390,7 @@ var ts; return unknownType; } if (!canUseSuperExpression) { - if (container && container.kind === 134 /* ComputedPropertyName */) { + if (container && container.kind === 136 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -18877,7 +19401,7 @@ var ts; } return unknownType; } - if (container.kind === 142 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 144 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; @@ -18892,7 +19416,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 142 /* Constructor */; + return container.kind === 144 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -18902,19 +19426,19 @@ var ts; // topmost container must be something that is directly nested in the class declaration if (container && ts.isClassLike(container.parent)) { if (container.flags & 128 /* Static */) { - return container.kind === 141 /* MethodDeclaration */ || - container.kind === 140 /* MethodSignature */ || - container.kind === 143 /* GetAccessor */ || - container.kind === 144 /* SetAccessor */; + return container.kind === 143 /* MethodDeclaration */ || + container.kind === 142 /* MethodSignature */ || + container.kind === 145 /* GetAccessor */ || + container.kind === 146 /* SetAccessor */; } else { - return container.kind === 141 /* MethodDeclaration */ || - container.kind === 140 /* MethodSignature */ || - container.kind === 143 /* GetAccessor */ || - container.kind === 144 /* SetAccessor */ || - container.kind === 139 /* PropertyDeclaration */ || - container.kind === 138 /* PropertySignature */ || - container.kind === 142 /* Constructor */; + return container.kind === 143 /* MethodDeclaration */ || + container.kind === 142 /* MethodSignature */ || + container.kind === 145 /* GetAccessor */ || + container.kind === 146 /* SetAccessor */ || + container.kind === 141 /* PropertyDeclaration */ || + container.kind === 140 /* PropertySignature */ || + container.kind === 144 /* Constructor */; } } } @@ -18955,7 +19479,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 136 /* Parameter */) { + if (declaration.kind === 138 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -18988,7 +19512,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 136 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 138 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -18999,8 +19523,8 @@ var ts; // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 142 /* Constructor */ || - functionDecl.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144 /* SetAccessor */))) { + functionDecl.kind === 144 /* Constructor */ || + functionDecl.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -19022,7 +19546,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 168 /* TaggedTemplateExpression */) { + if (template.parent.kind === 170 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -19030,13 +19554,13 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) { + if (operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { // In an assignment expression, the right operand is contextually typed by the type of the left operand. if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 51 /* BarBarToken */) { + else if (operator === 52 /* BarBarToken */) { // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand. var type = getContextualType(binaryExpression); @@ -19143,7 +19667,7 @@ var ts; } function getContextualTypeForJsxExpression(expr) { // Contextual type only applies to JSX expressions that are in attribute assignments (not in 'Children' positions) - if (expr.parent.kind === 236 /* JsxAttribute */) { + if (expr.parent.kind === 238 /* JsxAttribute */) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -19153,7 +19677,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 237 /* JsxSpreadAttribute */) { + if (expr.kind === 239 /* JsxSpreadAttribute */) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -19174,38 +19698,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 209 /* VariableDeclaration */: - case 136 /* Parameter */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 163 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 172 /* ArrowFunction */: - case 202 /* ReturnStatement */: + case 174 /* ArrowFunction */: + case 204 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 182 /* YieldExpression */: + case 184 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 169 /* TypeAssertionExpression */: - case 187 /* AsExpression */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 243 /* PropertyAssignment */: + case 245 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 188 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 181 /* TemplateExpression */); + case 190 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 183 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return getContextualType(parent); - case 238 /* JsxExpression */: - case 237 /* JsxSpreadAttribute */: + case 240 /* JsxExpression */: + case 239 /* JsxSpreadAttribute */: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -19222,7 +19746,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 171 /* FunctionExpression */ || node.kind === 172 /* ArrowFunction */; + return node.kind === 173 /* FunctionExpression */ || node.kind === 174 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -19236,7 +19760,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -19299,13 +19823,13 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 179 /* BinaryExpression */ && parent.operatorToken.kind === 55 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 181 /* BinaryExpression */ && parent.operatorToken.kind === 56 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 243 /* PropertyAssignment */) { + if (parent.kind === 245 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 162 /* ArrayLiteralExpression */) { + if (parent.kind === 164 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -19321,8 +19845,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function hasDefaultValue(node) { - return (node.kind === 161 /* BindingElement */ && !!node.initializer) || - (node.kind === 179 /* BinaryExpression */ && node.operatorToken.kind === 55 /* EqualsToken */); + return (node.kind === 163 /* BindingElement */ && !!node.initializer) || + (node.kind === 181 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -19331,7 +19855,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 183 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 185 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -19355,7 +19879,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 183 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 185 /* SpreadElementExpression */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -19370,7 +19894,7 @@ var ts; var pattern = contextualType.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. - if (pattern && (pattern.kind === 160 /* ArrayBindingPattern */ || pattern.kind === 162 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 162 /* ArrayBindingPattern */ || pattern.kind === 164 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -19378,7 +19902,7 @@ var ts; elementTypes.push(contextualType.elementTypes[i]); } else { - if (patternElement.kind !== 185 /* OmittedExpression */) { + if (patternElement.kind !== 187 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -19393,7 +19917,7 @@ var ts; return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 134 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 136 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, @@ -19443,30 +19967,30 @@ var ts; return links.resolvedType; } function checkObjectLiteral(node, contextualMapper) { + var inDestructuringPattern = isAssignmentTarget(node); // Grammar checking - checkGrammarObjectLiteralExpression(node); + checkGrammarObjectLiteralExpression(node, inDestructuringPattern); var propertiesTable = {}; var propertiesArray = []; var contextualType = getContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 159 /* ObjectBindingPattern */ || contextualType.pattern.kind === 163 /* ObjectLiteralExpression */); - var inDestructuringPattern = isAssignmentTarget(node); + (contextualType.pattern.kind === 161 /* ObjectBindingPattern */ || contextualType.pattern.kind === 165 /* ObjectLiteralExpression */); var typeFlags = 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 243 /* PropertyAssignment */ || - memberDecl.kind === 244 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 245 /* PropertyAssignment */ || + memberDecl.kind === 246 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 243 /* PropertyAssignment */) { + if (memberDecl.kind === 245 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 141 /* MethodDeclaration */) { + else if (memberDecl.kind === 143 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 244 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 246 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -19474,7 +19998,9 @@ var ts; if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - if (memberDecl.kind === 243 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) { + var isOptional = (memberDecl.kind === 245 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 246 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + if (isOptional) { prop.flags |= 536870912 /* Optional */; } } @@ -19504,7 +20030,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 143 /* GetAccessor */ || memberDecl.kind === 144 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 145 /* GetAccessor */ || memberDecl.kind === 146 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -19566,7 +20092,7 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 67 /* Identifier */) { + if (lhs.kind === 69 /* Identifier */) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && @@ -19587,18 +20113,18 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 238 /* JsxExpression */: + case 240 /* JsxExpression */: checkJsxExpression(child); break; - case 231 /* JsxElement */: + case 233 /* JsxElement */: checkJsxElement(child); break; - case 232 /* JsxSelfClosingElement */: + case 234 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; default: // No checks for JSX Text - ts.Debug.assert(child.kind === 234 /* JsxText */); + ts.Debug.assert(child.kind === 236 /* JsxText */); } } return jsxElementType || anyType; @@ -19614,7 +20140,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 133 /* QualifiedName */) { + if (tagName.kind === 135 /* QualifiedName */) { return false; } else { @@ -19733,12 +20259,14 @@ var ts; // Look up the value in the current scope if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4 /* ClassElement */; - getSymbolLinks(valueSymbol).referenced = true; + if (valueSymbol.flags & 8388608 /* Alias */) { + markAliasSymbolAsReferenced(valueSymbol); + } } return valueSymbol || unknownSymbol; } function resolveJsxTagName(node) { - if (node.tagName.kind === 67 /* Identifier */) { + if (node.tagName.kind === 69 /* Identifier */) { var tag = node.tagName; var sym = getResolvedSymbol(tag); return sym.exportSymbol || sym; @@ -19923,11 +20451,11 @@ var ts; // thus should have their types ignored var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 236 /* JsxAttribute */) { + if (node.attributes[i].kind === 238 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 237 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 239 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -19957,7 +20485,7 @@ var ts; // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 139 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 141 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; @@ -19973,8 +20501,8 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 93 /* SuperKeyword */) { - var errorNode = node.kind === 164 /* PropertyAccessExpression */ ? + if (left.kind === 95 /* SuperKeyword */) { + var errorNode = node.kind === 166 /* PropertyAccessExpression */ ? node.name : node.right; // TS 1.0 spec (April 2014): 4.8.2 @@ -19984,7 +20512,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (getDeclarationKindFromSymbol(prop) !== 141 /* MethodDeclaration */) { + if (getDeclarationKindFromSymbol(prop) !== 143 /* MethodDeclaration */) { // `prop` refers to a *property* declared in the super class // rather than a *method*, so it does not satisfy the above criteria. error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -20017,7 +20545,7 @@ var ts; } // Property is known to be protected at this point // All protected properties of a supertype are accessible in a super access - if (left.kind === 93 /* SuperKeyword */) { + if (left.kind === 95 /* SuperKeyword */) { return true; } // A protected property is accessible in the declaring class and classes derived from it @@ -20030,6 +20558,10 @@ var ts; return true; } // An instance property must be accessed through an instance of the enclosing class + if (type.flags & 33554432 /* ThisType */) { + // get the original type -- represented as the type constraint of the 'this' type + type = getConstraintOfTypeParameter(type); + } // TODO: why is the first part of this check here? if (!(getTargetType(type).flags & (1024 /* Class */ | 2048 /* Interface */) && hasBaseType(type, enclosingClass))) { error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); @@ -20056,18 +20588,18 @@ var ts; var prop = getPropertyOfType(apparentType, right.text); if (!prop) { if (right.text) { - error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type)); + error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type.flags & 33554432 /* ThisType */ ? apparentType : type)); } return unknownType; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32 /* Class */) { - checkClassPropertyAccess(node, left, type, prop); + checkClassPropertyAccess(node, left, apparentType, prop); } return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 164 /* PropertyAccessExpression */ + var left = node.kind === 166 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -20083,7 +20615,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 167 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 169 /* NewExpression */ && 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); @@ -20155,6 +20687,7 @@ var ts; } /** * If indexArgumentExpression is a string literal or number literal, returns its text. + * If indexArgumentExpression is a constant value, returns its string value. * If indexArgumentExpression is a well known symbol, returns the property name corresponding * to this symbol, as long as it is a proper symbol reference. * Otherwise, returns undefined. @@ -20163,6 +20696,12 @@ var ts; if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { return indexArgumentExpression.text; } + if (indexArgumentExpression.kind === 167 /* ElementAccessExpression */ || indexArgumentExpression.kind === 166 /* PropertyAccessExpression */) { + var value = getConstantValue(indexArgumentExpression); + if (value !== undefined) { + return value.toString(); + } + } if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) { var rightHandSideName = indexArgumentExpression.name.text; return ts.getPropertyNameForKnownSymbolName(rightHandSideName); @@ -20212,10 +20751,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 168 /* TaggedTemplateExpression */) { + if (node.kind === 170 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 137 /* Decorator */) { + else if (node.kind !== 139 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -20281,7 +20820,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 183 /* SpreadElementExpression */) { + if (arg && arg.kind === 185 /* SpreadElementExpression */) { return i; } } @@ -20293,13 +20832,13 @@ var ts; var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments var isDecorator; var spreadArgIndex = -1; - if (node.kind === 168 /* TaggedTemplateExpression */) { + if (node.kind === 170 /* TaggedTemplateExpression */) { var tagExpression = node; // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 181 /* TemplateExpression */) { + if (tagExpression.template.kind === 183 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var templateExpression = tagExpression.template; @@ -20316,7 +20855,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 137 /* Decorator */) { + else if (node.kind === 139 /* Decorator */) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); @@ -20325,7 +20864,7 @@ var ts; var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 167 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 169 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -20404,7 +20943,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 187 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type @@ -20463,7 +21002,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 187 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); @@ -20495,16 +21034,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 168 /* TaggedTemplateExpression */) { + if (node.kind === 170 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 181 /* TemplateExpression */) { + if (template.kind === 183 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 137 /* Decorator */) { + else if (node.kind === 139 /* Decorator */) { // For a decorator, we return undefined as we will determine // the number and types of arguments for a decorator using // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. @@ -20529,25 +21068,29 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 137 /* Decorator */) { + if (node.kind === 139 /* Decorator */) { switch (node.parent.kind) { - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts) + // If we are emitting decorators for ES3, we will only pass two arguments. + if (languageVersion === 0 /* ES3 */) { + return 2; + } // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 136 /* Parameter */: + case 138 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -20572,25 +21115,25 @@ var ts; function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. switch (node.kind) { - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 136 /* Parameter */: + case 138 /* Parameter */: // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 142 /* Constructor */) { + if (node.kind === 144 /* Constructor */) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } // fall-through - case 139 /* PropertyDeclaration */: - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: // For a property or method decorator, the `target` is the // "static"-side type of the parent of the member if the member is // declared "static"; otherwise, it is the "instance"-side type of the @@ -20619,33 +21162,33 @@ var ts; function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 136 /* Parameter */: + case 138 /* Parameter */: node = node.parent; - if (node.kind === 142 /* Constructor */) { + if (node.kind === 144 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } // For a non-constructor parameter decorator, the `propertyKey` will be either // a string or a symbol, based on the name of the parameter's containing method. // fall-through - case 139 /* PropertyDeclaration */: - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: // The `propertyKey` for a property or method decorator will be a // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will // be either string or symbol. var element = node; switch (element.name.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return getStringLiteralType(element.name); - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) { return nameType; @@ -20673,18 +21216,18 @@ var ts; // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a paramter decorator switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 136 /* Parameter */: + case 138 /* Parameter */: // The `parameterIndex` for a parameter decorator is always a number return numberType; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -20717,10 +21260,10 @@ var ts; // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors - if (node.kind === 137 /* Decorator */) { + if (node.kind === 139 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */) { return globalTemplateStringsArrayType; } // This is not a synthetic argument, so we return 'undefined' @@ -20732,8 +21275,8 @@ var ts; */ function getEffectiveArgument(node, args, argIndex) { // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 137 /* Decorator */ || - (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */)) { + if (node.kind === 139 /* Decorator */ || + (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -20742,11 +21285,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 137 /* Decorator */) { + if (node.kind === 139 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -20755,13 +21298,13 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 168 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 137 /* Decorator */; + var isTaggedTemplate = node.kind === 170 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 139 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (node.expression.kind !== 93 /* SuperKeyword */) { + if (node.expression.kind !== 95 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -20968,7 +21511,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 93 /* SuperKeyword */) { + if (node.expression.kind === 95 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated @@ -21101,16 +21644,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 136 /* Parameter */: + case 138 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -21147,16 +21690,16 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 166 /* CallExpression */) { + if (node.kind === 168 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 167 /* NewExpression */) { + else if (node.kind === 169 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 168 /* TaggedTemplateExpression */) { + else if (node.kind === 170 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 137 /* Decorator */) { + else if (node.kind === 139 /* Decorator */) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -21174,15 +21717,15 @@ var ts; // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 93 /* SuperKeyword */) { + if (node.expression.kind === 95 /* SuperKeyword */) { return voidType; } - if (node.kind === 167 /* NewExpression */) { + if (node.kind === 169 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 142 /* Constructor */ && - declaration.kind !== 146 /* ConstructSignature */ && - declaration.kind !== 151 /* ConstructorType */) { + declaration.kind !== 144 /* Constructor */ && + declaration.kind !== 148 /* ConstructSignature */ && + declaration.kind !== 153 /* ConstructorType */) { // When resolved signature is a call signature (and not a construct signature) the result type is any if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); @@ -21190,6 +21733,10 @@ var ts; return anyType; } } + // In JavaScript files, calls to any identifier 'require' are treated as external module imports + if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node)) { + return resolveExternalModuleTypeByLiteral(node.arguments[0]); + } return getReturnTypeOfSignature(signature); } function checkTaggedTemplateExpression(node) { @@ -21224,10 +21771,24 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } } + // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push + // the destructured type into the contained binding elements. + function assignBindingElementTypes(node) { + if (ts.isBindingPattern(node.name)) { + for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 187 /* OmittedExpression */) { + getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); + assignBindingElementTypes(element); + } + } + } + } function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { var links = getSymbolLinks(parameter); if (!links.type) { links.type = instantiateType(contextualType, mapper); + assignBindingElementTypes(parameter.valueDeclaration); } else if (isInferentialContext(mapper)) { // Even if the parameter already has a type, it might be because it was given a type while @@ -21279,7 +21840,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 190 /* Block */) { + if (func.body.kind !== 192 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -21398,7 +21959,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 206 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 208 /* ThrowStatement */); } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type @@ -21413,7 +21974,7 @@ var ts; return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 190 /* Block */) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192 /* Block */) { return; } var bodyBlock = func.body; @@ -21431,10 +21992,10 @@ 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 !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 171 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 173 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -21477,14 +22038,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -21506,7 +22067,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 190 /* Block */) { + if (node.body.kind === 192 /* Block */) { checkSourceElement(node.body); } else { @@ -21552,24 +22113,24 @@ var ts; // and property accesses(section 4.10). // All other expression constructs described in this chapter are classified as values. switch (n.kind) { - case 67 /* Identifier */: { + case 69 /* Identifier */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.3 // An identifier expression that references a variable or parameter is classified as a reference. // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; } - case 164 /* PropertyAccessExpression */: { + case 166 /* PropertyAccessExpression */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.10 // A property access expression is always classified as a reference. // NOTE (not in spec): assignment to enum members should not be allowed return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; } - case 165 /* ElementAccessExpression */: - // old compiler doesn't check indexed assess + case 167 /* ElementAccessExpression */: + // old compiler doesn't check indexed access return true; - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -21577,12 +22138,12 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 67 /* Identifier */: - case 164 /* PropertyAccessExpression */: { + case 69 /* Identifier */: + case 166 /* PropertyAccessExpression */: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768 /* Const */) !== 0; } - case 165 /* ElementAccessExpression */: { + case 167 /* ElementAccessExpression */: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 9 /* StringLiteral */) { @@ -21592,7 +22153,7 @@ var ts; } return false; } - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -21638,15 +22199,15 @@ var ts; switch (node.operator) { case 35 /* PlusToken */: case 36 /* MinusToken */: - case 49 /* TildeToken */: + case 50 /* TildeToken */: if (someConstituentTypeHasKind(operandType, 16777216 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 48 /* ExclamationToken */: + case 49 /* ExclamationToken */: return booleanType; - case 40 /* PlusPlusToken */: - case 41 /* MinusMinusToken */: + case 41 /* PlusPlusToken */: + case 42 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -21706,31 +22267,31 @@ var ts; function isConstEnumSymbol(symbol) { return (symbol.flags & 128 /* ConstEnum */) !== 0; } - function checkInstanceOfExpression(node, leftType, rightType) { + function checkInstanceOfExpression(left, right, leftType, rightType) { // TypeScript 1.0 spec (April 2014): 4.15.4 // The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type, // and the right operand to be of type Any or a subtype of the 'Function' interface type. // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported if (allConstituentTypesHaveKind(leftType, 16777726 /* Primitive */)) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); + error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; } - function checkInExpression(node, leftType, rightType) { + function checkInExpression(left, right, leftType, rightType) { // TypeScript 1.0 spec (April 2014): 4.15.5 // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); + error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } @@ -21738,7 +22299,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) { + if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var name_13 = p.name; var type = isTypeAny(sourceType) @@ -21747,7 +22308,12 @@ var ts; isNumericLiteralName(name_13.text) && getIndexTypeOfType(sourceType, 1 /* Number */) || getIndexTypeOfType(sourceType, 0 /* String */); if (type) { - checkDestructuringAssignment(p.initializer || name_13, type); + if (p.kind === 246 /* ShorthandPropertyAssignment */) { + checkDestructuringAssignment(p, type); + } + else { + checkDestructuringAssignment(p.initializer || name_13, type); + } } else { error(name_13, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_13)); @@ -21767,8 +22333,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 185 /* OmittedExpression */) { - if (e.kind !== 183 /* SpreadElementExpression */) { + if (e.kind !== 187 /* OmittedExpression */) { + if (e.kind !== 185 /* SpreadElementExpression */) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -21793,7 +22359,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 179 /* BinaryExpression */ && restExpression.operatorToken.kind === 55 /* EqualsToken */) { + if (restExpression.kind === 181 /* BinaryExpression */ && restExpression.operatorToken.kind === 56 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -21805,15 +22371,26 @@ var ts; } return sourceType; } - function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) { + function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { + var target; + if (exprOrAssignment.kind === 246 /* ShorthandPropertyAssignment */) { + var prop = exprOrAssignment; + if (prop.objectAssignmentInitializer) { + checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); + } + target = exprOrAssignment.name; + } + else { + target = exprOrAssignment; + } + if (target.kind === 181 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 163 /* ObjectLiteralExpression */) { + if (target.kind === 165 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 162 /* ArrayLiteralExpression */) { + if (target.kind === 164 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -21826,34 +22403,39 @@ var ts; return sourceType; } function checkBinaryExpression(node, contextualMapper) { - var operator = node.operatorToken.kind; - if (operator === 55 /* EqualsToken */ && (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); + return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); + } + function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { + var operator = operatorToken.kind; + if (operator === 56 /* EqualsToken */ && (left.kind === 165 /* ObjectLiteralExpression */ || left.kind === 164 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } - var leftType = checkExpression(node.left, contextualMapper); - var rightType = checkExpression(node.right, contextualMapper); + var leftType = checkExpression(left, contextualMapper); + var rightType = checkExpression(right, contextualMapper); switch (operator) { case 37 /* AsteriskToken */: - case 58 /* AsteriskEqualsToken */: - case 38 /* SlashToken */: - case 59 /* SlashEqualsToken */: - case 39 /* PercentToken */: - case 60 /* PercentEqualsToken */: + case 38 /* AsteriskAsteriskToken */: + case 59 /* AsteriskEqualsToken */: + case 60 /* AsteriskAsteriskEqualsToken */: + case 39 /* SlashToken */: + case 61 /* SlashEqualsToken */: + case 40 /* PercentToken */: + case 62 /* PercentEqualsToken */: case 36 /* MinusToken */: - case 57 /* MinusEqualsToken */: - case 42 /* LessThanLessThanToken */: - case 61 /* LessThanLessThanEqualsToken */: - case 43 /* GreaterThanGreaterThanToken */: - case 62 /* GreaterThanGreaterThanEqualsToken */: - case 44 /* GreaterThanGreaterThanGreaterThanToken */: - case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 46 /* BarToken */: - case 65 /* BarEqualsToken */: - case 47 /* CaretToken */: - case 66 /* CaretEqualsToken */: - case 45 /* AmpersandToken */: - case 64 /* AmpersandEqualsToken */: - // TypeScript 1.0 spec (April 2014): 4.15.1 + case 58 /* MinusEqualsToken */: + case 43 /* LessThanLessThanToken */: + case 63 /* LessThanLessThanEqualsToken */: + case 44 /* GreaterThanGreaterThanToken */: + case 64 /* GreaterThanGreaterThanEqualsToken */: + case 45 /* GreaterThanGreaterThanGreaterThanToken */: + case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 47 /* BarToken */: + case 67 /* BarEqualsToken */: + case 48 /* CaretToken */: + case 68 /* CaretEqualsToken */: + case 46 /* AmpersandToken */: + case 66 /* AmpersandEqualsToken */: + // TypeScript 1.0 spec (April 2014): 4.19.1 // These operators require their operands to be of type Any, the Number primitive type, // or an enum type. Operands of an enum type are treated // as having the primitive type Number. If one operand is the null or undefined value, @@ -21868,21 +22450,21 @@ var ts; // try and return them a helpful suggestion if ((leftType.flags & 8 /* Boolean */) && (rightType.flags & 8 /* Boolean */) && - (suggestedOperator = getSuggestedBooleanOperator(node.operatorToken.kind)) !== undefined) { - error(node, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(node.operatorToken.kind), ts.tokenToString(suggestedOperator)); + (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { + error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); } else { // otherwise just check each operand separately and report errors as normal - var leftOk = checkArithmeticOperandType(node.left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(node.right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); if (leftOk && rightOk) { checkAssignmentOperator(numberType); } } return numberType; case 35 /* PlusToken */: - case 56 /* PlusEqualsToken */: - // TypeScript 1.0 spec (April 2014): 4.15.2 + case 57 /* PlusEqualsToken */: + // TypeScript 1.0 spec (April 2014): 4.19.2 // The binary + operator requires both operands to be of the Number primitive type or an enum type, // or at least one of the operands to be of type Any or the String primitive type. // If one operand is the null or undefined value, it is treated as having the type of the other operand. @@ -21915,7 +22497,7 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 56 /* PlusEqualsToken */) { + if (operator === 57 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; @@ -21935,15 +22517,15 @@ var ts; reportOperatorError(); } return booleanType; - case 89 /* InstanceOfKeyword */: - return checkInstanceOfExpression(node, leftType, rightType); - case 88 /* InKeyword */: - return checkInExpression(node, leftType, rightType); - case 50 /* AmpersandAmpersandToken */: + case 91 /* InstanceOfKeyword */: + return checkInstanceOfExpression(left, right, leftType, rightType); + case 90 /* InKeyword */: + return checkInExpression(left, right, leftType, rightType); + case 51 /* AmpersandAmpersandToken */: return rightType; - case 51 /* BarBarToken */: + case 52 /* BarBarToken */: return getUnionType([leftType, rightType]); - case 55 /* EqualsToken */: + case 56 /* EqualsToken */: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); case 24 /* CommaToken */: @@ -21951,8 +22533,8 @@ var ts; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? node.left : - someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? left : + someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -21962,37 +22544,37 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 46 /* BarToken */: - case 65 /* BarEqualsToken */: - return 51 /* BarBarToken */; - case 47 /* CaretToken */: - case 66 /* CaretEqualsToken */: + case 47 /* BarToken */: + case 67 /* BarEqualsToken */: + return 52 /* BarBarToken */; + case 48 /* CaretToken */: + case 68 /* CaretEqualsToken */: return 33 /* ExclamationEqualsEqualsToken */; - case 45 /* AmpersandToken */: - case 64 /* AmpersandEqualsToken */: - return 50 /* AmpersandAmpersandToken */; + case 46 /* AmpersandToken */: + case 66 /* AmpersandEqualsToken */: + return 51 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) { + if (produceDiagnostics && operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { // TypeScript 1.0 spec (April 2014): 4.17 // An assignment of the form // VarExpr = ValueExpr // requires VarExpr to be classified as a reference // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) // and the type of the non - compound operation to be assignable to the type of VarExpr. - 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); + var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); // Use default messages if (ok) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, node.left, /*headMessage*/ undefined); + checkTypeAssignableTo(valueType, leftType, left, /*headMessage*/ undefined); } } } function reportOperatorError() { - error(node, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(node.operatorToken.kind), typeToString(leftType), typeToString(rightType)); + error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); } } function isYieldExpressionInClass(node) { @@ -22083,7 +22665,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 134 /* ComputedPropertyName */) { + if (node.name.kind === 136 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -22094,7 +22676,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 134 /* ComputedPropertyName */) { + if (node.name.kind === 136 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -22124,7 +22706,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 133 /* QualifiedName */) { + if (node.kind === 135 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -22136,9 +22718,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */) && 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); } @@ -22152,78 +22734,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: return checkIdentifier(node); - case 95 /* ThisKeyword */: + case 97 /* ThisKeyword */: return checkThisExpression(node); - case 93 /* SuperKeyword */: + case 95 /* SuperKeyword */: return checkSuperExpression(node); - case 91 /* NullKeyword */: + case 93 /* NullKeyword */: return nullType; - case 97 /* TrueKeyword */: - case 82 /* FalseKeyword */: + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: return booleanType; case 8 /* NumericLiteral */: return checkNumericLiteral(node); - case 181 /* TemplateExpression */: + case 183 /* TemplateExpression */: return checkTemplateExpression(node); case 9 /* StringLiteral */: case 11 /* NoSubstitutionTemplateLiteral */: return stringType; case 10 /* RegularExpressionLiteral */: return globalRegExpType; - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 164 /* PropertyAccessExpression */: + case 166 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 165 /* ElementAccessExpression */: + case 167 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: return checkCallExpression(node); - case 168 /* TaggedTemplateExpression */: + case 170 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 184 /* ClassExpression */: + case 186 /* ClassExpression */: return checkClassExpression(node); - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 174 /* TypeOfExpression */: + case 176 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 169 /* TypeAssertionExpression */: - case 187 /* AsExpression */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: return checkAssertion(node); - case 173 /* DeleteExpression */: + case 175 /* DeleteExpression */: return checkDeleteExpression(node); - case 175 /* VoidExpression */: + case 177 /* VoidExpression */: return checkVoidExpression(node); - case 176 /* AwaitExpression */: + case 178 /* AwaitExpression */: return checkAwaitExpression(node); - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 178 /* PostfixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 183 /* SpreadElementExpression */: + case 185 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 185 /* OmittedExpression */: + case 187 /* OmittedExpression */: return undefinedType; - case 182 /* YieldExpression */: + case 184 /* YieldExpression */: return checkYieldExpression(node); - case 238 /* JsxExpression */: + case 240 /* JsxExpression */: return checkJsxExpression(node); - case 231 /* JsxElement */: + case 233 /* JsxElement */: return checkJsxElement(node); - case 232 /* JsxSelfClosingElement */: + case 234 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 233 /* JsxOpeningElement */: + case 235 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -22252,7 +22834,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 142 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 144 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -22269,15 +22851,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 141 /* MethodDeclaration */ || - node.kind === 211 /* FunctionDeclaration */ || - node.kind === 171 /* FunctionExpression */; + return node.kind === 143 /* MethodDeclaration */ || + node.kind === 213 /* FunctionDeclaration */ || + node.kind === 173 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 67 /* Identifier */ && + if (param.name.kind === 69 /* Identifier */ && param.name.text === parameter.text) { return i; } @@ -22287,31 +22869,31 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { - case 172 /* ArrowFunction */: - case 145 /* CallSignature */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 150 /* FunctionType */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 174 /* ArrowFunction */: + case 147 /* CallSignature */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 152 /* FunctionType */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 147 /* IndexSignature */) { + if (node.kind === 149 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 150 /* FunctionType */ || node.kind === 211 /* FunctionDeclaration */ || node.kind === 151 /* ConstructorType */ || - node.kind === 145 /* CallSignature */ || node.kind === 142 /* Constructor */ || - node.kind === 146 /* ConstructSignature */) { + else if (node.kind === 152 /* FunctionType */ || node.kind === 213 /* FunctionDeclaration */ || node.kind === 153 /* ConstructorType */ || + node.kind === 147 /* CallSignature */ || node.kind === 144 /* Constructor */ || + node.kind === 148 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 148 /* TypePredicate */) { + if (node.type.kind === 150 /* TypePredicate */) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -22330,19 +22912,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 159 /* ObjectBindingPattern */ || - param.name.kind === 160 /* ArrayBindingPattern */) { + if (param.name.kind === 161 /* ObjectBindingPattern */ || + param.name.kind === 162 /* ArrayBindingPattern */) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 67 /* Identifier */ && + if (element.name.kind === 69 /* Identifier */ && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 160 /* ArrayBindingPattern */ || - element.name.kind === 159 /* ObjectBindingPattern */) { + else if (element.name.kind === 162 /* ArrayBindingPattern */ || + element.name.kind === 161 /* ObjectBindingPattern */) { checkBindingPattern(element.name); } } @@ -22366,10 +22948,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 146 /* ConstructSignature */: + case 148 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 145 /* CallSignature */: + case 147 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -22397,7 +22979,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 213 /* InterfaceDeclaration */) { + if (node.kind === 215 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -22417,7 +22999,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 128 /* StringKeyword */: + case 130 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -22425,7 +23007,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 126 /* NumberKeyword */: + case 128 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -22474,7 +23056,7 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 166 /* CallExpression */ && n.expression.kind === 93 /* SuperKeyword */; + return n.kind === 168 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; } function containsSuperCallAsComputedPropertyName(n) { return n.name && containsSuperCall(n.name); @@ -22492,15 +23074,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 95 /* ThisKeyword */) { + if (n.kind === 97 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 171 /* FunctionExpression */ && n.kind !== 211 /* FunctionDeclaration */) { + else if (n.kind !== 173 /* FunctionExpression */ && n.kind !== 213 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 139 /* PropertyDeclaration */ && + return n.kind === 141 /* PropertyDeclaration */ && !(n.flags & 128 /* Static */) && !!n.initializer; } @@ -22530,7 +23112,7 @@ var ts; var superCallStatement; for (var _i = 0; _i < statements.length; _i++) { var statement = statements[_i]; - if (statement.kind === 193 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { + if (statement.kind === 195 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; } @@ -22556,7 +23138,7 @@ var ts; if (produceDiagnostics) { // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 143 /* GetAccessor */) { + if (node.kind === 145 /* GetAccessor */) { 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); } @@ -22564,7 +23146,7 @@ var ts; if (!ts.hasDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 143 /* GetAccessor */ ? 144 /* SetAccessor */ : 143 /* GetAccessor */; + var otherKind = node.kind === 145 /* GetAccessor */ ? 146 /* SetAccessor */ : 145 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { @@ -22660,9 +23242,9 @@ var ts; var signaturesToCheck; // Unnamed (call\construct) signatures in interfaces are inherited and not shadowed so examining just node symbol won't give complete answer. // Use declaring type to obtain full list of signatures. - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 145 /* CallSignature */ || signatureDeclarationNode.kind === 146 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 145 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 215 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 147 /* CallSignature */ || signatureDeclarationNode.kind === 148 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 147 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -22680,7 +23262,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 213 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 215 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -22766,7 +23348,7 @@ var ts; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members - ts.Debug.assert(node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */); + ts.Debug.assert(node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */); ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -22802,7 +23384,7 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 213 /* InterfaceDeclaration */ || node.parent.kind === 153 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 215 /* InterfaceDeclaration */ || node.parent.kind === 155 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -22813,7 +23395,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 211 /* FunctionDeclaration */ || node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */ || node.kind === 142 /* Constructor */) { + if (node.kind === 213 /* FunctionDeclaration */ || node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */ || node.kind === 144 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -22953,16 +23535,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return d.name.kind === 9 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -22973,7 +23555,8 @@ var ts; } } function checkNonThenableType(type, location, message) { - if (!(type.flags & 1 /* Any */) && isTypeAssignableTo(type, getGlobalThenableType())) { + type = getWidenedType(type); + if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -23206,22 +23789,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 136 /* Parameter */: + case 138 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -23234,9 +23817,9 @@ var ts; // When we are emitting type metadata for decorators, we need to try to check the type // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. - if (node && node.kind === 149 /* TypeReference */) { + if (node && node.kind === 151 /* TypeReference */) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = root.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Resolve type so we know which symbol is referenced var rootSymbol = resolveName(root, root.text, meaning | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); // Resolved symbol is alias @@ -23255,19 +23838,19 @@ var ts; */ function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 136 /* Parameter */: + case 138 /* Parameter */: checkTypeNodeAsExpression(node.type); break; - case 141 /* MethodDeclaration */: + case 143 /* MethodDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 143 /* GetAccessor */: + case 145 /* GetAccessor */: checkTypeNodeAsExpression(node.type); break; - case 144 /* SetAccessor */: + case 146 /* SetAccessor */: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -23296,25 +23879,25 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 141 /* MethodDeclaration */: + case 143 /* MethodDeclaration */: checkParameterTypeAnnotationsAsExpressions(node); // fall-through - case 144 /* SetAccessor */: - case 143 /* GetAccessor */: - case 139 /* PropertyDeclaration */: - case 136 /* Parameter */: + case 146 /* SetAccessor */: + case 145 /* GetAccessor */: + case 141 /* PropertyDeclaration */: + case 138 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 136 /* Parameter */) { + if (node.kind === 138 /* Parameter */) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -23332,15 +23915,12 @@ var ts; checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { - if (!compilerOptions.experimentalAsyncFunctions) { - error(node, ts.Diagnostics.Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning); - } emitAwaiter = true; } // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 134 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 136 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -23389,11 +23969,11 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 190 /* Block */) { + if (node.kind === 192 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 217 /* ModuleBlock */) { + if (ts.isFunctionBlock(node) || node.kind === 219 /* ModuleBlock */) { checkFunctionAndClassExpressionBodies(node); } } @@ -23412,12 +23992,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 139 /* PropertyDeclaration */ || - node.kind === 138 /* PropertySignature */ || - node.kind === 141 /* MethodDeclaration */ || - node.kind === 140 /* MethodSignature */ || - node.kind === 143 /* GetAccessor */ || - node.kind === 144 /* SetAccessor */) { + if (node.kind === 141 /* PropertyDeclaration */ || + node.kind === 140 /* PropertySignature */ || + node.kind === 143 /* MethodDeclaration */ || + node.kind === 142 /* MethodSignature */ || + node.kind === 145 /* GetAccessor */ || + node.kind === 146 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -23426,7 +24006,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 136 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 138 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -23442,7 +24022,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 67 /* Identifier */; + var isDeclaration_1 = node.kind !== 69 /* Identifier */; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -23465,7 +24045,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 67 /* Identifier */; + var isDeclaration_2 = node.kind !== 69 /* Identifier */; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -23479,12 +24059,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 216 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 218 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 246 /* SourceFile */ && ts.isExternalModule(parent)) { + if (parent.kind === 248 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -23519,7 +24099,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 209 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 211 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -23529,17 +24109,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 191 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 193 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 190 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 217 /* ModuleBlock */ || - container.kind === 216 /* ModuleDeclaration */ || - container.kind === 246 /* SourceFile */); + (container.kind === 192 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 219 /* ModuleBlock */ || + container.kind === 218 /* ModuleDeclaration */ || + container.kind === 248 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -23554,18 +24134,18 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 136 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 138 /* Parameter */) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 67 /* Identifier */) { + if (n.kind === 69 /* Identifier */) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name and if this entry matches the resolved symbol if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 136 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 138 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -23591,7 +24171,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 134 /* ComputedPropertyName */) { + if (node.name.kind === 136 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -23602,7 +24182,7 @@ var ts; ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 136 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 138 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -23634,10 +24214,10 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); } } - if (node.kind !== 139 /* PropertyDeclaration */ && node.kind !== 138 /* PropertySignature */) { + if (node.kind !== 141 /* PropertyDeclaration */ && node.kind !== 140 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) { + if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -23660,7 +24240,7 @@ var ts; } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && node.parent.kind === 163 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 165 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -23698,12 +24278,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 212 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer.kind === 212 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -23723,14 +24303,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer.kind === 212 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); // There may be a destructuring assignment on the left side - if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* ObjectLiteralExpression */) { + if (varExpr.kind === 164 /* ArrayLiteralExpression */ || varExpr.kind === 165 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -23759,7 +24339,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer.kind === 212 /* VariableDeclarationList */) { 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); @@ -23773,7 +24353,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* ObjectLiteralExpression */) { + if (varExpr.kind === 164 /* ArrayLiteralExpression */ || varExpr.kind === 165 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { @@ -24012,7 +24592,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144 /* SetAccessor */))); + return !!(node.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -24035,10 +24615,10 @@ var ts; // for generators. return; } - if (func.kind === 144 /* SetAccessor */) { + if (func.kind === 146 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 142 /* Constructor */) { + else if (func.kind === 144 /* Constructor */) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -24047,7 +24627,12 @@ var ts; if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - checkTypeAssignableTo(awaitedType, promisedType, node.expression); + if (promisedType) { + // If the function has a return type, but promisedType is + // undefined, an error will be reported in checkAsyncFunctionReturnType + // so we don't need to report one here. + checkTypeAssignableTo(awaitedType, promisedType, node.expression); + } } else { checkTypeAssignableTo(exprType, returnType, node.expression); @@ -24074,7 +24659,7 @@ var ts; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 240 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 242 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -24086,7 +24671,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 239 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 241 /* CaseClause */) { var caseClause = clause; // TypeScript 1.0 spec (April 2014):5.9 // In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression. @@ -24107,7 +24692,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 205 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 207 /* LabeledStatement */ && 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; @@ -24137,7 +24722,7 @@ var ts; if (catchClause) { // Grammar checking if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 67 /* Identifier */) { + if (catchClause.variableDeclaration.name.kind !== 69 /* Identifier */) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -24212,7 +24797,7 @@ var ts; // perform property check if property or indexer is declared in 'type' // this allows to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (prop.valueDeclaration.name.kind === 134 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 136 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -24289,6 +24874,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { @@ -24307,7 +24893,7 @@ var ts; } } } - checkTypeAssignableTo(type, baseType, node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify @@ -24324,7 +24910,8 @@ var ts; } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { - ts.forEach(implementedTypeNodes, function (typeRefNode) { + for (var _b = 0; _b < implementedTypeNodes.length; _b++) { + var typeRefNode = implementedTypeNodes[_b]; if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } @@ -24334,14 +24921,14 @@ var ts; if (t !== unknownType) { var declaredType = (t.flags & 4096 /* Reference */) ? t.target : t; if (declaredType.flags & (1024 /* Class */ | 2048 /* Interface */)) { - checkTypeAssignableTo(type, t, node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { error(typeRefNode, ts.Diagnostics.A_class_may_only_implement_another_class_or_interface); } } } - }); + } } if (produceDiagnostics) { checkIndexConstraints(type); @@ -24392,7 +24979,7 @@ var ts; // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 256 /* Abstract */))) { - if (derivedClassDecl.kind === 184 /* ClassExpression */) { + if (derivedClassDecl.kind === 186 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -24440,7 +25027,7 @@ var ts; } } function isAccessor(kind) { - return kind === 143 /* GetAccessor */ || kind === 144 /* SetAccessor */; + return kind === 145 /* GetAccessor */ || kind === 146 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -24480,7 +25067,7 @@ var ts; var ok = true; for (var _i = 0; _i < baseTypes.length; _i++) { var base = baseTypes[_i]; - var properties = getPropertiesOfObjectType(base); + var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); for (var _a = 0; _a < properties.length; _a++) { var prop = properties[_a]; if (!ts.hasProperty(seen, prop.name)) { @@ -24510,7 +25097,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 215 /* InterfaceDeclaration */); 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); @@ -24519,19 +25106,21 @@ var ts; // Only check this symbol once if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); // run subsequent checks only if first set succeeded if (checkInheritedPropertiesAreIdentical(type, node.name)) { - ts.forEach(getBaseTypes(type), function (baseType) { - checkTypeAssignableTo(type, baseType, node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); - }); + for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) { + var baseType = _a[_i]; + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); + } checkIndexConstraints(type); } } // Interfaces cannot merge with non-ambient classes. if (symbol && symbol.declarations) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 212 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var declaration = _c[_b]; + if (declaration.kind === 214 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } @@ -24560,24 +25149,38 @@ var ts; if (!(nodeLinks.flags & 8192 /* EnumValuesComputed */)) { var enumSymbol = getSymbolOfNode(node); var enumType = getDeclaredTypeOfSymbol(enumSymbol); - var autoValue = 0; + var autoValue = 0; // set to undefined when enum member is non-constant var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); - ts.forEach(node.members, function (member) { - if (member.name.kind !== 134 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.name.kind === 136 /* ComputedPropertyName */) { + error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); + } + else if (isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } + var previousEnumMemberIsNonConstant = autoValue === undefined; var initializer = member.initializer; if (initializer) { autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); } else if (ambient && !enumIsConst) { + // In ambient enum declarations that specify no const modifier, enum member declarations + // that omit a value are considered computed members (as opposed to having auto-incremented values assigned). autoValue = undefined; } + else if (previousEnumMemberIsNonConstant) { + // If the member declaration specifies no value, the member is considered a constant enum member. + // If the member is the first member in the enum declaration, it is assigned the value zero. + // Otherwise, it is assigned the value of the immediately preceding member plus one, + // and an error occurs if the immediately preceding member is not a constant enum member + error(member.name, ts.Diagnostics.Enum_member_must_have_initializer); + } if (autoValue !== undefined) { getNodeLinks(member).enumMemberValue = autoValue++; } - }); + } nodeLinks.flags |= 8192 /* EnumValuesComputed */; } function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { @@ -24590,11 +25193,11 @@ var ts; if (enumIsConst) { error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); } - else if (!ambient) { + else if (ambient) { + error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); + } + else { // Only here do we need to check that the initializer is assignable to the enum type. - // If it is a constant value (not undefined), it is syntactically constrained to be a number. - // Also, we do not need to check this for ambients because there is already - // a syntax error if it is not a constant. checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); } } @@ -24610,7 +25213,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -24618,10 +25221,10 @@ var ts; switch (e.operator) { case 35 /* PlusToken */: return value_1; case 36 /* MinusToken */: return -value_1; - case 49 /* TildeToken */: return ~value_1; + case 50 /* TildeToken */: return ~value_1; } return undefined; - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -24631,31 +25234,31 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 46 /* BarToken */: return left | right; - case 45 /* AmpersandToken */: return left & right; - case 43 /* GreaterThanGreaterThanToken */: return left >> right; - case 44 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 42 /* LessThanLessThanToken */: return left << right; - case 47 /* CaretToken */: return left ^ right; + case 47 /* BarToken */: return left | right; + case 46 /* AmpersandToken */: return left & right; + case 44 /* GreaterThanGreaterThanToken */: return left >> right; + case 45 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 43 /* LessThanLessThanToken */: return left << right; + case 48 /* CaretToken */: return left ^ right; case 37 /* AsteriskToken */: return left * right; - case 38 /* SlashToken */: return left / right; + case 39 /* SlashToken */: return left / right; case 35 /* PlusToken */: return left + right; case 36 /* MinusToken */: return left - right; - case 39 /* PercentToken */: return left % right; + case 40 /* PercentToken */: return left % right; } return undefined; case 8 /* NumericLiteral */: return +e.text; - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return evalConstant(e.expression); - case 67 /* Identifier */: - case 165 /* ElementAccessExpression */: - case 164 /* PropertyAccessExpression */: + case 69 /* Identifier */: + case 167 /* ElementAccessExpression */: + case 166 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName; - if (e.kind === 67 /* Identifier */) { + if (e.kind === 69 /* Identifier */) { // unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work. // instead pick current enum type and later try to fetch member from the type enumType_1 = currentType; @@ -24663,7 +25266,7 @@ var ts; } else { var expression; - if (e.kind === 165 /* ElementAccessExpression */) { + if (e.kind === 167 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -24678,10 +25281,10 @@ var ts; // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName var current = expression; while (current) { - if (current.kind === 67 /* Identifier */) { + if (current.kind === 69 /* Identifier */) { break; } - else if (current.kind === 164 /* PropertyAccessExpression */) { + else if (current.kind === 166 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -24707,7 +25310,7 @@ var ts; return undefined; } // illegal case: forward reference - if (!isDefinedBefore(propertyDecl, member)) { + if (!isBlockScopedNameDeclaredBeforeUse(propertyDecl, member)) { reportError = false; error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; @@ -24722,7 +25325,7 @@ var ts; return; } // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -24752,7 +25355,7 @@ var ts; var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 215 /* EnumDeclaration */) { + if (declaration.kind !== 217 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -24775,8 +25378,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 212 /* ClassDeclaration */ || - (declaration.kind === 211 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 214 /* ClassDeclaration */ || + (declaration.kind === 213 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -24832,7 +25435,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 212 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 214 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -24841,9 +25444,9 @@ var ts; // Checks for ambient external modules. if (isAmbientExternalModule) { if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); } - if (isExternalModuleNameRelative(node.name.text)) { + if (ts.isExternalModuleNameRelative(node.name.text)) { error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); } } @@ -24852,17 +25455,17 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 133 /* QualifiedName */) { + if (node.kind === 135 /* QualifiedName */) { node = node.left; } - else if (node.kind === 164 /* PropertyAccessExpression */) { + else if (node.kind === 166 /* PropertyAccessExpression */) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 67 /* Identifier */); + ts.Debug.assert(node.kind === 69 /* Identifier */); return node; } function checkExternalImportOrExportDeclaration(node) { @@ -24871,14 +25474,14 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; - if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 226 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 219 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 248 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 228 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; } - if (inAmbientExternalModule && isExternalModuleNameRelative(moduleName.text)) { + if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { // TypeScript 1.0 spec (April 2013): 12.1.6 // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference // other external modules only through top - level external module names. @@ -24896,7 +25499,7 @@ var ts; (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 228 /* ExportSpecifier */ ? + var message = node.kind === 230 /* ExportSpecifier */ ? 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)); @@ -24923,7 +25526,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -24960,9 +25563,9 @@ var ts; } } else { - if (languageVersion >= 2 /* ES6 */ && !ts.isInAmbientContext(node)) { + if (modulekind === 5 /* ES6 */ && !ts.isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above - 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); + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } } @@ -24980,8 +25583,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; - if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 219 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 248 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -24995,7 +25598,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 246 /* SourceFile */ && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 216 /* ModuleDeclaration */) { + if (node.parent.kind !== 248 /* SourceFile */ && node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 218 /* ModuleDeclaration */) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -25010,8 +25613,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 246 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 216 /* ModuleDeclaration */ && container.name.kind === 67 /* Identifier */) { + var container = node.parent.kind === 248 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 218 /* ModuleDeclaration */ && container.name.kind === 69 /* Identifier */) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -25019,7 +25622,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 67 /* Identifier */) { + if (node.expression.kind === 69 /* Identifier */) { markExportAsReferenced(node); } else { @@ -25027,21 +25630,21 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (languageVersion >= 2 /* ES6 */) { - // export assignment is deprecated in es6 or above - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + if (modulekind === 5 /* ES6 */) { + // export assignment is not supported in es6 modules + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); } - else if (compilerOptions.module === 4 /* System */) { + else if (modulekind === 4 /* System */) { // system modules does not support export assignment grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); } } } function getModuleStatements(node) { - if (node.kind === 246 /* SourceFile */) { + if (node.kind === 248 /* SourceFile */) { return node.statements; } - if (node.kind === 216 /* ModuleDeclaration */ && node.body.kind === 217 /* ModuleBlock */) { + if (node.kind === 218 /* ModuleDeclaration */ && node.body.kind === 219 /* ModuleBlock */) { return node.body.statements; } return emptyArray; @@ -25080,118 +25683,118 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessivly // hitting the cancellation token on every node we check. switch (kind) { - case 216 /* ModuleDeclaration */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 211 /* FunctionDeclaration */: + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 135 /* TypeParameter */: + case 137 /* TypeParameter */: return checkTypeParameter(node); - case 136 /* Parameter */: + case 138 /* Parameter */: return checkParameter(node); - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return checkPropertyDeclaration(node); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 147 /* IndexSignature */: + case 149 /* IndexSignature */: return checkSignatureDeclaration(node); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return checkMethodDeclaration(node); - case 142 /* Constructor */: + case 144 /* Constructor */: return checkConstructorDeclaration(node); - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return checkAccessorDeclaration(node); - case 149 /* TypeReference */: + case 151 /* TypeReference */: return checkTypeReferenceNode(node); - case 148 /* TypePredicate */: + case 150 /* TypePredicate */: return checkTypePredicate(node); - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return checkTypeQuery(node); - case 153 /* TypeLiteral */: + case 155 /* TypeLiteral */: return checkTypeLiteral(node); - case 154 /* ArrayType */: + case 156 /* ArrayType */: return checkArrayType(node); - case 155 /* TupleType */: + case 157 /* TupleType */: return checkTupleType(node); - case 156 /* UnionType */: - case 157 /* IntersectionType */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 158 /* ParenthesizedType */: + case 160 /* ParenthesizedType */: return checkSourceElement(node.type); - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 190 /* Block */: - case 217 /* ModuleBlock */: + case 192 /* Block */: + case 219 /* ModuleBlock */: return checkBlock(node); - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: return checkVariableStatement(node); - case 193 /* ExpressionStatement */: + case 195 /* ExpressionStatement */: return checkExpressionStatement(node); - case 194 /* IfStatement */: + case 196 /* IfStatement */: return checkIfStatement(node); - case 195 /* DoStatement */: + case 197 /* DoStatement */: return checkDoStatement(node); - case 196 /* WhileStatement */: + case 198 /* WhileStatement */: return checkWhileStatement(node); - case 197 /* ForStatement */: + case 199 /* ForStatement */: return checkForStatement(node); - case 198 /* ForInStatement */: + case 200 /* ForInStatement */: return checkForInStatement(node); - case 199 /* ForOfStatement */: + case 201 /* ForOfStatement */: return checkForOfStatement(node); - case 200 /* ContinueStatement */: - case 201 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 202 /* ReturnStatement */: + case 204 /* ReturnStatement */: return checkReturnStatement(node); - case 203 /* WithStatement */: + case 205 /* WithStatement */: return checkWithStatement(node); - case 204 /* SwitchStatement */: + case 206 /* SwitchStatement */: return checkSwitchStatement(node); - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: return checkLabeledStatement(node); - case 206 /* ThrowStatement */: + case 208 /* ThrowStatement */: return checkThrowStatement(node); - case 207 /* TryStatement */: + case 209 /* TryStatement */: return checkTryStatement(node); - case 209 /* VariableDeclaration */: + case 211 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 161 /* BindingElement */: + case 163 /* BindingElement */: return checkBindingElement(node); - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: return checkClassDeclaration(node); - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: return checkImportDeclaration(node); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return checkExportDeclaration(node); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return checkExportAssignment(node); - case 192 /* EmptyStatement */: + case 194 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 208 /* DebuggerStatement */: + case 210 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 229 /* MissingDeclaration */: + case 231 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -25206,97 +25809,98 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 184 /* ClassExpression */: + case 186 /* ClassExpression */: ts.forEach(node.members, checkSourceElement); + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 203 /* WithStatement */: + case 205 /* WithStatement */: checkFunctionAndClassExpressionBodies(node.expression); break; - case 137 /* Decorator */: - case 136 /* Parameter */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 159 /* ObjectBindingPattern */: - case 160 /* ArrayBindingPattern */: - case 161 /* BindingElement */: - case 162 /* ArrayLiteralExpression */: - case 163 /* ObjectLiteralExpression */: - case 243 /* PropertyAssignment */: - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 168 /* TaggedTemplateExpression */: - case 181 /* TemplateExpression */: - case 188 /* TemplateSpan */: - case 169 /* TypeAssertionExpression */: - case 187 /* AsExpression */: - case 170 /* ParenthesizedExpression */: - case 174 /* TypeOfExpression */: - case 175 /* VoidExpression */: - case 176 /* AwaitExpression */: - case 173 /* DeleteExpression */: - case 177 /* PrefixUnaryExpression */: - case 178 /* PostfixUnaryExpression */: - case 179 /* BinaryExpression */: - case 180 /* ConditionalExpression */: - case 183 /* SpreadElementExpression */: - case 182 /* YieldExpression */: - case 190 /* Block */: - case 217 /* ModuleBlock */: - case 191 /* VariableStatement */: - case 193 /* ExpressionStatement */: - case 194 /* IfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 200 /* ContinueStatement */: - case 201 /* BreakStatement */: - case 202 /* ReturnStatement */: - case 204 /* SwitchStatement */: - case 218 /* CaseBlock */: - case 239 /* CaseClause */: - case 240 /* DefaultClause */: - case 205 /* LabeledStatement */: - case 206 /* ThrowStatement */: - case 207 /* TryStatement */: - case 242 /* CatchClause */: - case 209 /* VariableDeclaration */: - case 210 /* VariableDeclarationList */: - case 212 /* ClassDeclaration */: - case 241 /* HeritageClause */: - case 186 /* ExpressionWithTypeArguments */: - case 215 /* EnumDeclaration */: - case 245 /* EnumMember */: - case 225 /* ExportAssignment */: - case 246 /* SourceFile */: - case 238 /* JsxExpression */: - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - case 236 /* JsxAttribute */: - case 237 /* JsxSpreadAttribute */: - case 233 /* JsxOpeningElement */: + case 139 /* Decorator */: + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + case 163 /* BindingElement */: + case 164 /* ArrayLiteralExpression */: + case 165 /* ObjectLiteralExpression */: + case 245 /* PropertyAssignment */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 170 /* TaggedTemplateExpression */: + case 183 /* TemplateExpression */: + case 190 /* TemplateSpan */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: + case 172 /* ParenthesizedExpression */: + case 176 /* TypeOfExpression */: + case 177 /* VoidExpression */: + case 178 /* AwaitExpression */: + case 175 /* DeleteExpression */: + case 179 /* PrefixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: + case 181 /* BinaryExpression */: + case 182 /* ConditionalExpression */: + case 185 /* SpreadElementExpression */: + case 184 /* YieldExpression */: + case 192 /* Block */: + case 219 /* ModuleBlock */: + case 193 /* VariableStatement */: + case 195 /* ExpressionStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: + case 204 /* ReturnStatement */: + case 206 /* SwitchStatement */: + case 220 /* CaseBlock */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + case 207 /* LabeledStatement */: + case 208 /* ThrowStatement */: + case 209 /* TryStatement */: + case 244 /* CatchClause */: + case 211 /* VariableDeclaration */: + case 212 /* VariableDeclarationList */: + case 214 /* ClassDeclaration */: + case 243 /* HeritageClause */: + case 188 /* ExpressionWithTypeArguments */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 227 /* ExportAssignment */: + case 248 /* SourceFile */: + case 240 /* JsxExpression */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 238 /* JsxAttribute */: + case 239 /* JsxSpreadAttribute */: + case 235 /* JsxOpeningElement */: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -25323,7 +25927,7 @@ var ts; potentialThisCollisions.length = 0; ts.forEach(node.statements, checkSourceElement); checkFunctionAndClassExpressionBodies(node); - if (ts.isExternalModule(node)) { + if (ts.isExternalOrCommonJsModule(node)) { checkExternalModuleExports(node); } if (potentialThisCollisions.length) { @@ -25382,7 +25986,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 203 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 205 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -25405,34 +26009,34 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 246 /* SourceFile */: - if (!ts.isExternalModule(location)) { + case 248 /* SourceFile */: + if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 184 /* ClassExpression */: + case 186 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } // fall through; this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, - // add the type parameters into the symbol table + // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!(memberFlags & 128 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 171 /* FunctionExpression */: + case 173 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -25475,43 +26079,43 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 67 /* Identifier */ && + return name.kind === 69 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 135 /* TypeParameter */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 215 /* EnumDeclaration */: + case 137 /* TypeParameter */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 217 /* EnumDeclaration */: return true; } } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 133 /* QualifiedName */) { + while (node.parent && node.parent.kind === 135 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 149 /* TypeReference */; + return node.parent && node.parent.kind === 151 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 164 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 166 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 186 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 188 /* ExpressionWithTypeArguments */; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 133 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 135 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 219 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 221 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 225 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 227 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -25523,11 +26127,11 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 225 /* ExportAssignment */) { + if (entityName.parent.kind === 227 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 164 /* PropertyAccessExpression */) { + if (entityName.kind !== 166 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -25537,13 +26141,24 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 186 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = 0 /* None */; + // In an interface or class, we're definitely interested in a type. + if (entityName.parent.kind === 188 /* ExpressionWithTypeArguments */) { + meaning = 793056 /* Type */; + // In a class 'extends' clause we are also looking for a value. + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + meaning |= 107455 /* Value */; + } + } + else { + meaning = 1536 /* Namespace */; + } meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 233 /* JsxOpeningElement */) || - (entityName.parent.kind === 232 /* JsxSelfClosingElement */) || - (entityName.parent.kind === 235 /* JsxClosingElement */)) { + else if ((entityName.parent.kind === 235 /* JsxOpeningElement */) || + (entityName.parent.kind === 234 /* JsxSelfClosingElement */) || + (entityName.parent.kind === 237 /* JsxClosingElement */)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { @@ -25551,20 +26166,20 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 67 /* Identifier */) { + if (entityName.kind === 69 /* Identifier */) { // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 164 /* PropertyAccessExpression */) { + else if (entityName.kind === 166 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 133 /* QualifiedName */) { + else if (entityName.kind === 135 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -25573,16 +26188,16 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 236 /* JsxAttribute */) { + else if (entityName.parent.kind === 238 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 148 /* TypePredicate */) { + if (entityName.parent.kind === 150 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? @@ -25597,14 +26212,14 @@ var ts; // This is a declaration, call getSymbolOfNode return getSymbolOfNode(node.parent); } - if (node.kind === 67 /* Identifier */) { + if (node.kind === 69 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 225 /* ExportAssignment */ + return node.parent.kind === 227 /* ExportAssignment */ ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } - else if (node.parent.kind === 161 /* BindingElement */ && - node.parent.parent.kind === 159 /* ObjectBindingPattern */ && + else if (node.parent.kind === 163 /* BindingElement */ && + node.parent.parent.kind === 161 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -25614,18 +26229,18 @@ var ts; } } switch (node.kind) { - case 67 /* Identifier */: - case 164 /* PropertyAccessExpression */: - case 133 /* QualifiedName */: + case 69 /* Identifier */: + case 166 /* PropertyAccessExpression */: + case 135 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 95 /* ThisKeyword */: - case 93 /* SuperKeyword */: - var type = checkExpression(node); + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: + var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 119 /* ConstructorKeyword */: + case 121 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 142 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 144 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -25633,14 +26248,14 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 220 /* ImportDeclaration */ || node.parent.kind === 226 /* ExportDeclaration */) && + ((node.parent.kind === 222 /* ImportDeclaration */ || node.parent.kind === 228 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } // Fall through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -25657,7 +26272,7 @@ var ts; // The function returns a value symbol of an identifier in the short-hand property assignment. // This is necessary as an identifier in short-hand property assignment can contains two meaning: // property name and property value. - if (location && location.kind === 244 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 246 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */); } return undefined; @@ -25774,11 +26389,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 246 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 248 /* SourceFile */) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 216 /* ModuleDeclaration */ || n.kind === 215 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 218 /* ModuleDeclaration */ || n.kind === 217 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -25793,11 +26408,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 190 /* Block */: - case 218 /* CaseBlock */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 192 /* Block */: + case 220 /* CaseBlock */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: return true; } return false; @@ -25827,22 +26442,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 219 /* ImportEqualsDeclaration */: - case 221 /* ImportClause */: - case 222 /* NamespaceImport */: - case 224 /* ImportSpecifier */: - case 228 /* ExportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 225 /* ExportAssignment */: - return node.expression && node.expression.kind === 67 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 227 /* ExportAssignment */: + return node.expression && node.expression.kind === 69 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 246 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 248 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -25904,7 +26519,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 245 /* EnumMember */) { + if (node.kind === 247 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -25996,23 +26611,6 @@ var ts; var symbol = getReferencedValueSymbol(reference); return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; } - function getBlockScopedVariableId(n) { - ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 161 /* BindingElement */ || (n.parent.kind === 209 /* VariableDeclaration */ && n.parent.name === n); - var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || - getNodeLinks(n).resolvedSymbol || - resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); - var isLetOrConst = symbol && - (symbol.flags & 2 /* BlockScopedVariable */) && - symbol.valueDeclaration.parent.kind !== 242 /* CatchClause */; - if (isLetOrConst) { - // side-effect of calling this method: - // assign id to symbol if it was not yet set - getSymbolLinks(symbol); - return symbol.id; - } - return undefined; - } function instantiateSingleCallFunctionType(functionType, typeArguments) { if (functionType === unknownType) { return unknownType; @@ -26044,7 +26642,6 @@ var ts; isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, collectLinkedAliases: collectLinkedAliases, - getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, isOptionalParameter: isOptionalParameter @@ -26057,11 +26654,10 @@ var ts; }); // Initialize global symbol table ts.forEach(host.getSourceFiles(), function (file) { - if (!ts.isExternalModule(file)) { + if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } }); - // Initialize special symbols getSymbolLinks(undefinedSymbol).type = undefinedType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); getSymbolLinks(unknownSymbol).type = unknownType; @@ -26087,6 +26683,7 @@ var ts; getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); getGlobalThenableType = ts.memoize(createThenableType); + cjsRequireType = getExportedTypeFromNamespace("CommonJS", "Require"); // If we're in ES6 mode, load the TemplateStringsArray. // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. if (languageVersion >= 2 /* ES6 */) { @@ -26136,10 +26733,7 @@ var ts; if (!ts.nodeCanBeDecorated(node)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } - else if (languageVersion < 1 /* ES5 */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* SetAccessor */) { + else if (node.kind === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -26149,38 +26743,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 142 /* Constructor */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 147 /* IndexSignature */: - case 216 /* ModuleDeclaration */: - case 220 /* ImportDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 226 /* ExportDeclaration */: - case 225 /* ExportAssignment */: - case 136 /* Parameter */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 149 /* IndexSignature */: + case 218 /* ModuleDeclaration */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 228 /* ExportDeclaration */: + case 227 /* ExportAssignment */: + case 138 /* Parameter */: break; - case 211 /* FunctionDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116 /* AsyncKeyword */) && - node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { + case 213 /* FunctionDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118 /* AsyncKeyword */) && + node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 191 /* VariableStatement */: - case 214 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 193 /* VariableStatement */: + case 216 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 215 /* EnumDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72 /* ConstKeyword */) && - node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { + case 217 /* EnumDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74 /* ConstKeyword */) && + node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -26195,14 +26789,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { - case 110 /* PublicKeyword */: - case 109 /* ProtectedKeyword */: - case 108 /* PrivateKeyword */: + case 112 /* PublicKeyword */: + case 111 /* ProtectedKeyword */: + case 110 /* PrivateKeyword */: var text = void 0; - if (modifier.kind === 110 /* PublicKeyword */) { + if (modifier.kind === 112 /* PublicKeyword */) { text = "public"; } - else if (modifier.kind === 109 /* ProtectedKeyword */) { + else if (modifier.kind === 111 /* ProtectedKeyword */) { text = "protected"; lastProtected = modifier; } @@ -26219,11 +26813,11 @@ var ts; else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { + else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256 /* Abstract */) { - if (modifier.kind === 108 /* PrivateKeyword */) { + if (modifier.kind === 110 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -26232,17 +26826,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 111 /* StaticKeyword */: + case 113 /* StaticKeyword */: if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { + else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 136 /* Parameter */) { + else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256 /* Abstract */) { @@ -26251,7 +26845,7 @@ var ts; flags |= 128 /* Static */; lastStatic = modifier; break; - case 80 /* ExportKeyword */: + case 82 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -26264,42 +26858,42 @@ var ts; else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 212 /* ClassDeclaration */) { + else if (node.parent.kind === 214 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 136 /* Parameter */) { + else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 120 /* DeclareKeyword */: + case 122 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 212 /* ClassDeclaration */) { + else if (node.parent.kind === 214 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 136 /* Parameter */) { + else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 113 /* AbstractKeyword */: + case 115 /* AbstractKeyword */: if (flags & 256 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 212 /* ClassDeclaration */) { - if (node.kind !== 141 /* MethodDeclaration */) { + if (node.kind !== 214 /* ClassDeclaration */) { + if (node.kind !== 143 /* MethodDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 212 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { + if (!(node.parent.kind === 214 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128 /* Static */) { @@ -26311,14 +26905,14 @@ var ts; } flags |= 256 /* Abstract */; break; - case 116 /* AsyncKeyword */: + case 118 /* AsyncKeyword */: if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 136 /* Parameter */) { + else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512 /* Async */; @@ -26326,7 +26920,7 @@ var ts; break; } } - if (node.kind === 142 /* Constructor */) { + if (node.kind === 144 /* Constructor */) { if (flags & 128 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -26344,10 +26938,10 @@ var ts; } return; } - else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 136 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 138 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512 /* Async */) { @@ -26359,10 +26953,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 141 /* MethodDeclaration */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -26428,7 +27022,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 172 /* ArrowFunction */) { + if (node.kind === 174 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -26463,7 +27057,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 !== 128 /* StringKeyword */ && parameter.type.kind !== 126 /* NumberKeyword */) { + if (parameter.type.kind !== 130 /* StringKeyword */ && parameter.type.kind !== 128 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -26496,7 +27090,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 185 /* OmittedExpression */) { + if (arg.kind === 187 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -26523,7 +27117,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 81 /* ExtendsKeyword */) { + if (heritageClause.token === 83 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -26536,7 +27130,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -26552,14 +27146,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 81 /* ExtendsKeyword */) { + if (heritageClause.token === 83 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -26570,19 +27164,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 134 /* ComputedPropertyName */) { + if (node.kind !== 136 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 179 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { + if (computedPropertyName.expression.kind === 181 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 211 /* FunctionDeclaration */ || - node.kind === 171 /* FunctionExpression */ || - node.kind === 141 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 213 /* FunctionDeclaration */ || + node.kind === 173 /* FunctionExpression */ || + node.kind === 143 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -26599,7 +27193,7 @@ var ts; return grammarErrorOnNode(questionToken, message); } } - function checkGrammarObjectLiteralExpression(node) { + function checkGrammarObjectLiteralExpression(node, inDestructuring) { var seen = {}; var Property = 1; var GetAccessor = 2; @@ -26608,12 +27202,17 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_16 = prop.name; - if (prop.kind === 185 /* OmittedExpression */ || - name_16.kind === 134 /* ComputedPropertyName */) { + if (prop.kind === 187 /* OmittedExpression */ || + name_16.kind === 136 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_16); continue; } + if (prop.kind === 246 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern + // outside of destructuring it is a syntax error + return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); + } // ECMA-262 11.1.5 Object Initialiser // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true // a.This production is contained in strict code and IsDataDescriptor(previous) is true and @@ -26623,7 +27222,7 @@ var ts; // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; - if (prop.kind === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */) { + if (prop.kind === 245 /* PropertyAssignment */ || prop.kind === 246 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_16.kind === 8 /* NumericLiteral */) { @@ -26631,13 +27230,13 @@ var ts; } currentKind = Property; } - else if (prop.kind === 141 /* MethodDeclaration */) { + else if (prop.kind === 143 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 143 /* GetAccessor */) { + else if (prop.kind === 145 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 144 /* SetAccessor */) { + else if (prop.kind === 146 /* SetAccessor */) { currentKind = SetAccesor; } else { @@ -26669,7 +27268,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 237 /* JsxSpreadAttribute */) { + if (attr.kind === 239 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; @@ -26681,7 +27280,7 @@ var ts; return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 238 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 240 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -26690,24 +27289,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 210 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 212 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ ? 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 === 198 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ ? 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 = forInOrOfStatement.kind === 198 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ ? 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); @@ -26730,10 +27329,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 143 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 145 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 144 /* SetAccessor */) { + else if (kind === 146 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -26758,7 +27357,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 134 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 136 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -26768,7 +27367,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 163 /* ObjectLiteralExpression */) { + if (node.parent.kind === 165 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -26792,22 +27391,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 === 213 /* InterfaceDeclaration */) { + else if (node.parent.kind === 215 /* InterfaceDeclaration */) { 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 === 153 /* TypeLiteral */) { + else if (node.parent.kind === 155 /* TypeLiteral */) { 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 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: return true; - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -26819,11 +27418,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 200 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 202 /* ContinueStatement */ && !isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -26831,8 +27430,8 @@ var ts; return false; } break; - case 204 /* SwitchStatement */: - if (node.kind === 201 /* BreakStatement */ && !node.label) { + case 206 /* SwitchStatement */: + if (node.kind === 203 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -26847,13 +27446,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 201 /* BreakStatement */ + var message = node.kind === 203 /* BreakStatement */ ? 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 === 201 /* BreakStatement */ + var message = node.kind === 203 /* BreakStatement */ ? 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); @@ -26865,7 +27464,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 160 /* ArrayBindingPattern */ || node.name.kind === 159 /* ObjectBindingPattern */) { + if (node.name.kind === 162 /* ArrayBindingPattern */ || node.name.kind === 161 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -26875,7 +27474,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 198 /* ForInStatement */ && node.parent.parent.kind !== 199 /* ForOfStatement */) { + if (node.parent.parent.kind !== 200 /* ForInStatement */ && node.parent.parent.kind !== 201 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -26902,7 +27501,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 67 /* Identifier */) { + if (name.kind === 69 /* Identifier */) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -26911,7 +27510,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 185 /* OmittedExpression */) { + if (element.kind !== 187 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -26928,15 +27527,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 194 /* IfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 203 /* WithStatement */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: return false; - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -26952,7 +27551,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 177 /* PrefixUnaryExpression */) { + if (expression.kind === 179 /* PrefixUnaryExpression */) { var unaryExpression = expression; if (unaryExpression.operator === 35 /* PlusToken */ || unaryExpression.operator === 36 /* MinusToken */) { expression = unaryExpression.operand; @@ -26968,37 +27567,6 @@ var ts; } return false; } - function checkGrammarEnumDeclaration(enumDecl) { - var enumIsConst = (enumDecl.flags & 32768 /* Const */) !== 0; - var hasError = false; - // skip checks below for const enums - they allow arbitrary initializers as long as they can be evaluated to constant expressions. - // since all values are known in compile time - it is not necessary to check that constant enum section precedes computed enum members. - if (!enumIsConst) { - var inConstantEnumMemberSection = true; - var inAmbientContext = ts.isInAmbientContext(enumDecl); - for (var _i = 0, _a = enumDecl.members; _i < _a.length; _i++) { - var node = _a[_i]; - // Do not use hasDynamicName here, because that returns false for well known symbols. - // We want to perform checkComputedPropertyName for all computed properties, including - // well known symbols. - if (node.name.kind === 134 /* ComputedPropertyName */) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); - } - else if (inAmbientContext) { - if (node.initializer && !isIntegerLiteral(node.initializer)) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers) || hasError; - } - } - else if (node.initializer) { - inConstantEnumMemberSection = isIntegerLiteral(node.initializer); - } - else if (!inConstantEnumMemberSection) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Enum_member_must_have_initializer) || hasError; - } - } - } - return hasError; - } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -27024,7 +27592,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 67 /* Identifier */ && + return node.kind === 69 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -27044,12 +27612,12 @@ var ts; return true; } } - else if (node.parent.kind === 213 /* InterfaceDeclaration */) { + else if (node.parent.kind === 215 /* InterfaceDeclaration */) { 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 === 153 /* TypeLiteral */) { + else if (node.parent.kind === 155 /* TypeLiteral */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -27069,11 +27637,11 @@ var ts; // export_opt ExternalImportDeclaration // export_opt AmbientDeclaration // - if (node.kind === 213 /* InterfaceDeclaration */ || - node.kind === 220 /* ImportDeclaration */ || - node.kind === 219 /* ImportEqualsDeclaration */ || - node.kind === 226 /* ExportDeclaration */ || - node.kind === 225 /* ExportAssignment */ || + if (node.kind === 215 /* InterfaceDeclaration */ || + node.kind === 222 /* ImportDeclaration */ || + node.kind === 221 /* ImportEqualsDeclaration */ || + node.kind === 228 /* ExportDeclaration */ || + node.kind === 227 /* ExportAssignment */ || (node.flags & 2 /* Ambient */) || (node.flags & (1 /* Export */ | 1024 /* Default */))) { return false; @@ -27083,7 +27651,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 191 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 193 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -27109,7 +27677,7 @@ var ts; // to prevent noisyness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 190 /* Block */ || node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { + if (node.parent.kind === 192 /* Block */ || node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -27160,6 +27728,7 @@ var ts; var enclosingDeclaration; var currentSourceFile; var reportedDeclarationError = false; + var errorNameNode; var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var moduleElementDeclarationEmitInfo = []; @@ -27191,7 +27760,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 220 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 222 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -27245,6 +27814,7 @@ var ts; function createAndSetNewTextWriterWithSymbolWriter() { var writer = ts.createTextWriter(newLine); writer.trackSymbol = trackSymbol; + writer.reportInaccessibleThisError = reportInaccessibleThisError; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -27267,10 +27837,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 209 /* VariableDeclaration */) { + if (declaration.kind === 211 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 223 /* NamedImports */ || declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 221 /* ImportClause */) { + else if (declaration.kind === 225 /* NamedImports */ || declaration.kind === 226 /* ImportSpecifier */ || declaration.kind === 223 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -27288,7 +27858,7 @@ var ts; // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, // we would write alias foo declaration when we visit it since it would now be marked as visible if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 220 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 222 /* ImportDeclaration */) { // we have to create asynchronous output only after we have collected complete information // because it is possible to enable multiple bindings as asynchronously visible moduleElementEmitInfo.isVisible = true; @@ -27298,12 +27868,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 216 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 218 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 216 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 218 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -27337,6 +27907,11 @@ var ts; function trackSymbol(symbol, enclosingDeclaration, meaning) { handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); } + function reportInaccessibleThisError() { + if (errorNameNode) { + diagnostics.push(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode))); + } + } function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); @@ -27345,7 +27920,9 @@ var ts; emitType(type); } else { + errorNameNode = declaration.name; resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + errorNameNode = undefined; } } function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { @@ -27356,7 +27933,9 @@ var ts; emitType(signature.type); } else { + errorNameNode = signature.name; resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + errorNameNode = undefined; } } function emitLines(nodes) { @@ -27395,49 +27974,50 @@ var ts; } function emitType(type) { switch (type.kind) { - case 115 /* AnyKeyword */: - case 128 /* StringKeyword */: - case 126 /* NumberKeyword */: - case 118 /* BooleanKeyword */: - case 129 /* SymbolKeyword */: - case 101 /* VoidKeyword */: + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: + case 97 /* ThisKeyword */: case 9 /* StringLiteral */: return writeTextOfNode(currentSourceFile, type); - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 149 /* TypeReference */: + case 151 /* TypeReference */: return emitTypeReference(type); - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return emitTypeQuery(type); - case 154 /* ArrayType */: + case 156 /* ArrayType */: return emitArrayType(type); - case 155 /* TupleType */: + case 157 /* TupleType */: return emitTupleType(type); - case 156 /* UnionType */: + case 158 /* UnionType */: return emitUnionType(type); - case 157 /* IntersectionType */: + case 159 /* IntersectionType */: return emitIntersectionType(type); - case 158 /* ParenthesizedType */: + case 160 /* ParenthesizedType */: return emitParenType(type); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 153 /* TypeLiteral */: + case 155 /* TypeLiteral */: return emitTypeLiteral(type); - case 67 /* Identifier */: + case 69 /* Identifier */: return emitEntityName(type); - case 133 /* QualifiedName */: + case 135 /* QualifiedName */: return emitEntityName(type); - case 148 /* TypePredicate */: + case 150 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 67 /* Identifier */) { + if (entityName.kind === 69 /* Identifier */) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 133 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 133 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 135 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 135 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); @@ -27446,13 +28026,13 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 219 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 221 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 67 /* Identifier */ || node.expression.kind === 164 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 69 /* Identifier */ || node.expression.kind === 166 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -27533,7 +28113,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 67 /* Identifier */) { + if (node.expression.kind === 69 /* Identifier */) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -27553,7 +28133,7 @@ var ts; write(";"); writeLine(); // Make all the declarations visible for the export name - if (node.expression.kind === 67 /* Identifier */) { + if (node.expression.kind === 69 /* Identifier */) { var nodes = resolver.collectLinkedAliases(node.expression); // write each of these declarations asynchronously writeAsynchronousModuleElements(nodes); @@ -27572,10 +28152,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 219 /* ImportEqualsDeclaration */ || - (node.parent.kind === 246 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 221 /* ImportEqualsDeclaration */ || + (node.parent.kind === 248 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 248 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -27585,7 +28165,7 @@ var ts; }); } else { - if (node.kind === 220 /* ImportDeclaration */) { + if (node.kind === 222 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -27603,23 +28183,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: return writeVariableStatement(node); - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: return writeClassDeclaration(node); - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -27635,7 +28215,7 @@ var ts; if (node.flags & 1024 /* Default */) { write("default "); } - else if (node.kind !== 213 /* InterfaceDeclaration */) { + else if (node.kind !== 215 /* InterfaceDeclaration */) { write("declare "); } } @@ -27684,7 +28264,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 222 /* NamespaceImport */) { + if (namedBindings.kind === 224 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -27712,7 +28292,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 224 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -27770,7 +28350,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 217 /* ModuleBlock */) { + while (node.body.kind !== 219 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -27835,7 +28415,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 141 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 143 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -27846,15 +28426,15 @@ var ts; // If there is constraint present and this is not a type parameter of the private method emit the constraint if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 150 /* FunctionType */ || - node.parent.kind === 151 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 153 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 141 /* MethodDeclaration */ || - node.parent.kind === 140 /* MethodSignature */ || - node.parent.kind === 150 /* FunctionType */ || - node.parent.kind === 151 /* ConstructorType */ || - node.parent.kind === 145 /* CallSignature */ || - node.parent.kind === 146 /* ConstructSignature */); + if (node.parent.kind === 152 /* FunctionType */ || + node.parent.kind === 153 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 155 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 143 /* MethodDeclaration */ || + node.parent.kind === 142 /* MethodSignature */ || + node.parent.kind === 152 /* FunctionType */ || + node.parent.kind === 153 /* ConstructorType */ || + node.parent.kind === 147 /* CallSignature */ || + node.parent.kind === 148 /* ConstructSignature */); emitType(node.constraint); } else { @@ -27865,31 +28445,31 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 146 /* ConstructSignature */: + case 148 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 145 /* CallSignature */: + case 147 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { 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 === 212 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 214 /* ClassDeclaration */) { 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 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -27917,13 +28497,13 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 91 /* NullKeyword */) { + else if (!isImplementsList && node.expression.kind === 93 /* NullKeyword */) { write("null"); } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 212 /* ClassDeclaration */) { + if (node.parent.parent.kind === 214 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -28007,7 +28587,7 @@ var ts; function emitVariableDeclaration(node) { // If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted // so there is no check needed to see if declaration is visible - if (node.kind !== 209 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 211 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -28017,10 +28597,10 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentSourceFile, node.name); // If optional property emit ? - if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && node.parent.kind === 153 /* TypeLiteral */) { + if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && node.parent.kind === 155 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { @@ -28029,14 +28609,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 209 /* VariableDeclaration */) { + if (node.kind === 211 /* VariableDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? 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 === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) { + else if (node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (node.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? @@ -28045,7 +28625,7 @@ var ts; 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 === 212 /* ClassDeclaration */) { + else if (node.parent.kind === 214 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -28077,7 +28657,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 185 /* OmittedExpression */) { + if (element.kind !== 187 /* OmittedExpression */) { elements.push(element); } } @@ -28147,7 +28727,7 @@ var ts; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 143 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 145 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -28160,7 +28740,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 143 /* GetAccessor */ + return accessor.kind === 145 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -28169,7 +28749,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 144 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 146 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? @@ -28219,17 +28799,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 211 /* FunctionDeclaration */) { + if (node.kind === 213 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 141 /* MethodDeclaration */) { + else if (node.kind === 143 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 211 /* FunctionDeclaration */) { + if (node.kind === 213 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 142 /* Constructor */) { + else if (node.kind === 144 /* Constructor */) { write("constructor"); } else { @@ -28247,11 +28827,11 @@ var ts; } function emitSignatureDeclaration(node) { // Construct signature or constructor type write new Signature - if (node.kind === 146 /* ConstructSignature */ || node.kind === 151 /* ConstructorType */) { + if (node.kind === 148 /* ConstructSignature */ || node.kind === 153 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 147 /* IndexSignature */) { + if (node.kind === 149 /* IndexSignature */) { write("["); } else { @@ -28261,22 +28841,22 @@ var ts; enclosingDeclaration = node; // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 147 /* IndexSignature */) { + if (node.kind === 149 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 150 /* FunctionType */ || node.kind === 151 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 153 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 152 /* FunctionType */ || node.kind === 153 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 155 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 142 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 144 /* Constructor */ && !(node.flags & 32 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -28287,26 +28867,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 146 /* ConstructSignature */: + case 148 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named 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 145 /* CallSignature */: + case 147 /* CallSignature */: // Interfaces cannot have return types that cannot be named 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 147 /* IndexSignature */: + case 149 /* IndexSignature */: // Interfaces cannot have return types that cannot be named 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 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -28314,7 +28894,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 === 212 /* ClassDeclaration */) { + else if (node.parent.kind === 214 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -28328,7 +28908,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -28363,9 +28943,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 150 /* FunctionType */ || - node.parent.kind === 151 /* ConstructorType */ || - node.parent.parent.kind === 153 /* TypeLiteral */) { + if (node.parent.kind === 152 /* FunctionType */ || + node.parent.kind === 153 /* ConstructorType */ || + node.parent.parent.kind === 155 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { @@ -28381,24 +28961,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 142 /* Constructor */: + case 144 /* Constructor */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? 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; - case 146 /* ConstructSignature */: + case 148 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return 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; - case 145 /* CallSignature */: + case 147 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return 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; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -28406,7 +28986,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 === 212 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 214 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -28419,7 +28999,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -28431,12 +29011,12 @@ var ts; } function emitBindingPattern(bindingPattern) { // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. - if (bindingPattern.kind === 159 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 161 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 160 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 162 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -28455,7 +29035,7 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 185 /* OmittedExpression */) { + if (bindingElement.kind === 187 /* OmittedExpression */) { // If bindingElement is an omittedExpression (i.e. containing elision), // we will emit blank space (although this may differ from users' original code, // it allows emitSeparatedList to write separator appropriately) @@ -28464,7 +29044,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 161 /* BindingElement */) { + else if (bindingElement.kind === 163 /* BindingElement */) { if (bindingElement.propertyName) { // bindingElement has propertyName property in the following case: // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" @@ -28487,7 +29067,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 67 /* Identifier */); + ts.Debug.assert(bindingElement.name.kind === 69 /* Identifier */); // If the node is just an identifier, we will simply emit the text associated with the node's name // Example: // original: function foo({y = 10, x}) {} @@ -28503,40 +29083,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 211 /* FunctionDeclaration */: - case 216 /* ModuleDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 213 /* InterfaceDeclaration */: - case 212 /* ClassDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 215 /* EnumDeclaration */: + case 213 /* FunctionDeclaration */: + case 218 /* ModuleDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 215 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 217 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return emitExportDeclaration(node); - case 142 /* Constructor */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 144 /* Constructor */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return writeFunctionDeclaration(node); - case 146 /* ConstructSignature */: - case 145 /* CallSignature */: - case 147 /* IndexSignature */: + case 148 /* ConstructSignature */: + case 147 /* CallSignature */: + case 149 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return emitAccessorDeclaration(node); - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return emitPropertyDeclaration(node); - case 245 /* EnumMember */: + case 247 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return emitExportAssignment(node); - case 246 /* SourceFile */: + case 248 /* SourceFile */: return emitSourceFile(node); } } @@ -28587,6 +29167,261 @@ var ts; return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); } ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; + var entities = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; // Flags enum to track count of temp variables and a few dedicated names var TempFlags; (function (TempFlags) { @@ -28599,7 +29434,7 @@ var ts; // emit output for the __extends helper function var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; // emit output for the __decorate helper function - var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; + var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; // emit output for the __metadata helper function var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; // emit output for the __param helper function @@ -28607,6 +29442,7 @@ var ts; var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0 /* ES3 */; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */; var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var diagnostics = []; var newLine = host.getNewLine(); @@ -28711,6 +29547,14 @@ var ts; var sourceMapData; /** If removeComments is true, no leading-comments needed to be emitted **/ var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; + var moduleEmitDelegates = (_a = {}, + _a[5 /* ES6 */] = emitES6Module, + _a[2 /* AMD */] = emitAMDModule, + _a[4 /* System */] = emitSystemModule, + _a[3 /* UMD */] = emitUMDModule, + _a[1 /* CommonJS */] = emitCommonJSModule, + _a + ); if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { initializeEmitterWithSourceMaps(); } @@ -28798,19 +29642,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: return makeUniqueName(node.text); - case 216 /* ModuleDeclaration */: - case 215 /* EnumDeclaration */: + case 218 /* ModuleDeclaration */: + case 217 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 220 /* ImportDeclaration */: - case 226 /* ExportDeclaration */: + case 222 /* ImportDeclaration */: + case 228 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 211 /* FunctionDeclaration */: - case 212 /* ClassDeclaration */: - case 225 /* ExportAssignment */: + case 213 /* FunctionDeclaration */: + case 214 /* ClassDeclaration */: + case 227 /* ExportAssignment */: return generateNameForExportDefault(); - case 184 /* ClassExpression */: + case 186 /* ClassExpression */: return generateNameForClassExpression(); } } @@ -28982,7 +29826,7 @@ var ts; // unless it is a computed property. Then it is shown with brackets, // but the brackets are included in the name. var name_21 = node.name; - if (!name_21 || name_21.kind !== 134 /* ComputedPropertyName */) { + if (!name_21 || name_21.kind !== 136 /* ComputedPropertyName */) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -29000,20 +29844,20 @@ var ts; // The scope was already given a name use it recordScopeNameStart(scopeName); } - else if (node.kind === 211 /* FunctionDeclaration */ || - node.kind === 171 /* FunctionExpression */ || - node.kind === 141 /* MethodDeclaration */ || - node.kind === 140 /* MethodSignature */ || - node.kind === 143 /* GetAccessor */ || - node.kind === 144 /* SetAccessor */ || - node.kind === 216 /* ModuleDeclaration */ || - node.kind === 212 /* ClassDeclaration */ || - node.kind === 215 /* EnumDeclaration */) { + else if (node.kind === 213 /* FunctionDeclaration */ || + node.kind === 173 /* FunctionExpression */ || + node.kind === 143 /* MethodDeclaration */ || + node.kind === 142 /* MethodSignature */ || + node.kind === 145 /* GetAccessor */ || + node.kind === 146 /* SetAccessor */ || + node.kind === 218 /* ModuleDeclaration */ || + node.kind === 214 /* ClassDeclaration */ || + node.kind === 217 /* EnumDeclaration */) { // Declaration and has associated name use it if (node.name) { var name_22 = node.name; // For computed property names, the text will include the brackets - scopeName = name_22.kind === 134 /* ComputedPropertyName */ + scopeName = name_22.kind === 136 /* ComputedPropertyName */ ? ts.getTextOfNode(name_22) : node.name.text; } @@ -29125,7 +29969,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node); } - if (node.kind !== 246 /* SourceFile */) { + if (node.kind !== 248 /* SourceFile */) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); @@ -29153,7 +29997,7 @@ var ts; } // Create a temporary variable with a unique unused name. function createTempVariable(flags) { - var result = ts.createSynthesizedNode(67 /* Identifier */); + var result = ts.createSynthesizedNode(69 /* Identifier */); result.text = makeTempVariableName(flags); return result; } @@ -29398,10 +30242,10 @@ var ts; write("("); emit(tempVariable); // Now we emit the expressions - if (node.template.kind === 181 /* TemplateExpression */) { + if (node.template.kind === 183 /* TemplateExpression */) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 179 /* BinaryExpression */ + var needsParens = templateSpan.expression.kind === 181 /* BinaryExpression */ && templateSpan.expression.operatorToken.kind === 24 /* CommaToken */; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -29436,7 +30280,7 @@ var ts; // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== 170 /* ParenthesizedExpression */ + var needsParens = templateSpan.expression.kind !== 172 /* ParenthesizedExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; if (i > 0 || headEmitted) { // If this is the first span and the head was not emitted, then this templateSpan's @@ -29478,11 +30322,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: return parent.expression === template; - case 168 /* TaggedTemplateExpression */: - case 170 /* ParenthesizedExpression */: + case 170 /* TaggedTemplateExpression */: + case 172 /* ParenthesizedExpression */: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -29503,11 +30347,11 @@ var ts; // TODO (drosen): Note that we need to account for the upcoming 'yield' and // spread ('...') unary operators that are anticipated for ES6. switch (expression.kind) { - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: switch (expression.operatorToken.kind) { case 37 /* AsteriskToken */: - case 38 /* SlashToken */: - case 39 /* PercentToken */: + case 39 /* SlashToken */: + case 40 /* PercentToken */: return 1 /* GreaterThan */; case 35 /* PlusToken */: case 36 /* MinusToken */: @@ -29515,8 +30359,8 @@ var ts; default: return -1 /* LessThan */; } - case 182 /* YieldExpression */: - case 180 /* ConditionalExpression */: + case 184 /* YieldExpression */: + case 182 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -29531,7 +30375,7 @@ var ts; /// Emit a tag name, which is either '"div"' for lower-cased names, or /// 'Div' for upper-cased or dotted names function emitTagName(name) { - if (name.kind === 67 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { + if (name.kind === 69 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { write("\""); emit(name); write("\""); @@ -29565,8 +30409,8 @@ var ts; } } function emitJsxElement(openingNode, children) { - var syntheticReactRef = ts.createSynthesizedNode(67 /* Identifier */); - syntheticReactRef.text = 'React'; + var syntheticReactRef = ts.createSynthesizedNode(69 /* Identifier */); + syntheticReactRef.text = "React"; syntheticReactRef.parent = openingNode; // Call React.createElement(tag, ... emitLeadingComments(openingNode); @@ -29583,12 +30427,12 @@ var ts; // Either emit one big object literal (no spread attribs), or // a call to React.__spread var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 237 /* JsxSpreadAttribute */; })) { + if (ts.forEach(attrs, function (attr) { return attr.kind === 239 /* JsxSpreadAttribute */; })) { emitExpressionIdentifier(syntheticReactRef); write(".__spread("); var haveOpenedObjectLiteral = false; for (var i_1 = 0; i_1 < attrs.length; i_1++) { - if (attrs[i_1].kind === 237 /* JsxSpreadAttribute */) { + if (attrs[i_1].kind === 239 /* JsxSpreadAttribute */) { // If this is the first argument, we need to emit a {} as the first argument if (i_1 === 0) { write("{}, "); @@ -29603,7 +30447,7 @@ var ts; emit(attrs[i_1].expression); } else { - ts.Debug.assert(attrs[i_1].kind === 236 /* JsxAttribute */); + ts.Debug.assert(attrs[i_1].kind === 238 /* JsxAttribute */); if (haveOpenedObjectLiteral) { write(", "); } @@ -29637,11 +30481,11 @@ var ts; if (children) { for (var i = 0; i < children.length; i++) { // Don't emit empty expressions - if (children[i].kind === 238 /* JsxExpression */ && !(children[i].expression)) { + if (children[i].kind === 240 /* JsxExpression */ && !(children[i].expression)) { continue; } // Don't emit empty strings - if (children[i].kind === 234 /* JsxText */) { + if (children[i].kind === 236 /* JsxText */) { var text = getTextToEmit(children[i]); if (text !== undefined) { write(", \""); @@ -29659,11 +30503,11 @@ var ts; write(")"); // closes "React.createElement(" emitTrailingComments(openingNode); } - if (node.kind === 231 /* JsxElement */) { + if (node.kind === 233 /* JsxElement */) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 234 /* JsxSelfClosingElement */); emitJsxElement(node); } } @@ -29685,11 +30529,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 237 /* JsxSpreadAttribute */) { + if (attribs[i].kind === 239 /* JsxSpreadAttribute */) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 236 /* JsxAttribute */); + ts.Debug.assert(attribs[i].kind === 238 /* JsxAttribute */); emitJsxAttribute(attribs[i]); } } @@ -29697,11 +30541,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 232 /* JsxSelfClosingElement */)) { + if (node.attributes.length > 0 || (node.kind === 234 /* JsxSelfClosingElement */)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 232 /* JsxSelfClosingElement */) { + if (node.kind === 234 /* JsxSelfClosingElement */) { write("/>"); } else { @@ -29720,11 +30564,11 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 231 /* JsxElement */) { + if (node.kind === 233 /* JsxElement */) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 234 /* JsxSelfClosingElement */); emitJsxOpeningOrSelfClosingElement(node); } } @@ -29732,11 +30576,11 @@ var ts; // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. // For example, this is utilized when feeding in a result to Object.defineProperty. function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 161 /* BindingElement */); + ts.Debug.assert(node.kind !== 163 /* BindingElement */); if (node.kind === 9 /* StringLiteral */) { emitLiteral(node); } - else if (node.kind === 134 /* ComputedPropertyName */) { + else if (node.kind === 136 /* ComputedPropertyName */) { // if this is a decorated computed property, we will need to capture the result // of the property expression so that we can apply decorators later. This is to ensure // we don't introduce unintended side effects: @@ -29747,7 +30591,7 @@ var ts; // // The emit for the decorated computed property decorator is: // - // Object.defineProperty(C.prototype, _a, __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a))); + // __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a)); // if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { @@ -29780,60 +30624,61 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 162 /* ArrayLiteralExpression */: - case 179 /* BinaryExpression */: - case 166 /* CallExpression */: - case 239 /* CaseClause */: - case 134 /* ComputedPropertyName */: - case 180 /* ConditionalExpression */: - case 137 /* Decorator */: - case 173 /* DeleteExpression */: - case 195 /* DoStatement */: - case 165 /* ElementAccessExpression */: - case 225 /* ExportAssignment */: - case 193 /* ExpressionStatement */: - case 186 /* ExpressionWithTypeArguments */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 194 /* IfStatement */: - case 232 /* JsxSelfClosingElement */: - case 233 /* JsxOpeningElement */: - case 237 /* JsxSpreadAttribute */: - case 238 /* JsxExpression */: - case 167 /* NewExpression */: - case 170 /* ParenthesizedExpression */: - case 178 /* PostfixUnaryExpression */: - case 177 /* PrefixUnaryExpression */: - case 202 /* ReturnStatement */: - case 244 /* ShorthandPropertyAssignment */: - case 183 /* SpreadElementExpression */: - case 204 /* SwitchStatement */: - case 168 /* TaggedTemplateExpression */: - case 188 /* TemplateSpan */: - case 206 /* ThrowStatement */: - case 169 /* TypeAssertionExpression */: - case 174 /* TypeOfExpression */: - case 175 /* VoidExpression */: - case 196 /* WhileStatement */: - case 203 /* WithStatement */: - case 182 /* YieldExpression */: + case 164 /* ArrayLiteralExpression */: + case 189 /* AsExpression */: + case 181 /* BinaryExpression */: + case 168 /* CallExpression */: + case 241 /* CaseClause */: + case 136 /* ComputedPropertyName */: + case 182 /* ConditionalExpression */: + case 139 /* Decorator */: + case 175 /* DeleteExpression */: + case 197 /* DoStatement */: + case 167 /* ElementAccessExpression */: + case 227 /* ExportAssignment */: + case 195 /* ExpressionStatement */: + case 188 /* ExpressionWithTypeArguments */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 196 /* IfStatement */: + case 234 /* JsxSelfClosingElement */: + case 235 /* JsxOpeningElement */: + case 239 /* JsxSpreadAttribute */: + case 240 /* JsxExpression */: + case 169 /* NewExpression */: + case 172 /* ParenthesizedExpression */: + case 180 /* PostfixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: + case 204 /* ReturnStatement */: + case 246 /* ShorthandPropertyAssignment */: + case 185 /* SpreadElementExpression */: + case 206 /* SwitchStatement */: + case 170 /* TaggedTemplateExpression */: + case 190 /* TemplateSpan */: + case 208 /* ThrowStatement */: + case 171 /* TypeAssertionExpression */: + case 176 /* TypeOfExpression */: + case 177 /* VoidExpression */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 184 /* YieldExpression */: return true; - case 161 /* BindingElement */: - case 245 /* EnumMember */: - case 136 /* Parameter */: - case 243 /* PropertyAssignment */: - case 139 /* PropertyDeclaration */: - case 209 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 247 /* EnumMember */: + case 138 /* Parameter */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 211 /* VariableDeclaration */: return parent.initializer === node; - case 164 /* PropertyAccessExpression */: + case 166 /* PropertyAccessExpression */: return parent.expression === node; - case 172 /* ArrowFunction */: - case 171 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 173 /* FunctionExpression */: return parent.body === node; - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: return parent.moduleReference === node; - case 133 /* QualifiedName */: + case 135 /* QualifiedName */: return parent.left === node; } return false; @@ -29845,9 +30690,9 @@ var ts; } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 246 /* SourceFile */) { + if (container.kind === 248 /* SourceFile */) { // Identifier references module export - if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { + if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { write("exports."); } } @@ -29857,20 +30702,20 @@ var ts; write("."); } } - else if (languageVersion < 2 /* ES6 */) { + else if (modulekind !== 5 /* ES6 */) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 221 /* ImportClause */) { + if (declaration.kind === 223 /* ImportClause */) { // Identifier references default import write(getGeneratedNameForNode(declaration.parent)); write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 224 /* ImportSpecifier */) { + else if (declaration.kind === 226 /* ImportSpecifier */) { // Identifier references named import write(getGeneratedNameForNode(declaration.parent.parent.parent)); - var name = declaration.propertyName || declaration.name; - var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name); + var name_23 = declaration.propertyName || declaration.name; + var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name_23); if (languageVersion === 0 /* ES3 */ && identifier === "default") { write("[\"default\"]"); } @@ -29898,10 +30743,10 @@ var ts; if (languageVersion < 2 /* ES6 */) { var parent_6 = node.parent; switch (parent_6.kind) { - case 161 /* BindingElement */: - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: - case 209 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 211 /* VariableDeclaration */: return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); } } @@ -29979,7 +30824,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(112 /* YieldKeyword */)); + write(ts.tokenToString(114 /* YieldKeyword */)); if (node.asteriskToken) { write("*"); } @@ -29993,7 +30838,7 @@ var ts; if (needsParenthesis) { write("("); } - write(ts.tokenToString(112 /* YieldKeyword */)); + write(ts.tokenToString(114 /* YieldKeyword */)); write(" "); emit(node.expression); if (needsParenthesis) { @@ -30001,22 +30846,22 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 179 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 181 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 180 /* ConditionalExpression */ && node.parent.condition === node) { + else if (node.parent.kind === 182 /* ConditionalExpression */ && node.parent.condition === node) { return true; } return false; } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 67 /* Identifier */: - case 162 /* ArrayLiteralExpression */: - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: - case 166 /* CallExpression */: - case 170 /* ParenthesizedExpression */: + case 69 /* Identifier */: + case 164 /* ArrayLiteralExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 172 /* ParenthesizedExpression */: // This list is not exhaustive and only includes those cases that are relevant // to the check in emitArrayLiteral. More cases can be added as needed. return false; @@ -30036,17 +30881,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 183 /* SpreadElementExpression */) { + if (e.kind === 185 /* SpreadElementExpression */) { e = e.expression; emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162 /* ArrayLiteralExpression */) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 164 /* ArrayLiteralExpression */) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 183 /* SpreadElementExpression */) { + while (i < length && elements[i].kind !== 185 /* SpreadElementExpression */) { i++; } write("["); @@ -30069,7 +30914,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 183 /* SpreadElementExpression */; + return node.kind === 185 /* SpreadElementExpression */; } function emitArrayLiteral(node) { var elements = node.elements; @@ -30139,7 +30984,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 143 /* GetAccessor */ || property.kind === 144 /* SetAccessor */) { + if (property.kind === 145 /* GetAccessor */ || property.kind === 146 /* SetAccessor */) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { @@ -30191,13 +31036,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 243 /* PropertyAssignment */) { + if (property.kind === 245 /* PropertyAssignment */) { emit(property.initializer); } - else if (property.kind === 244 /* ShorthandPropertyAssignment */) { + else if (property.kind === 246 /* ShorthandPropertyAssignment */) { emitExpressionIdentifier(property.name); } - else if (property.kind === 141 /* MethodDeclaration */) { + else if (property.kind === 143 /* MethodDeclaration */) { emitFunctionDeclaration(property); } else { @@ -30231,7 +31076,7 @@ var ts; // Everything until that point can be emitted as part of the initial object literal. var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 134 /* ComputedPropertyName */) { + if (properties[i].name.kind === 136 /* ComputedPropertyName */) { numInitialNonComputedProperties = i; break; } @@ -30247,21 +31092,21 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(179 /* BinaryExpression */, startsOnNewLine); + var result = ts.createSynthesizedNode(181 /* BinaryExpression */, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(164 /* PropertyAccessExpression */); + var result = ts.createSynthesizedNode(166 /* PropertyAccessExpression */); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(21 /* DotToken */); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(165 /* ElementAccessExpression */); + var result = ts.createSynthesizedNode(167 /* ElementAccessExpression */); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; @@ -30269,7 +31114,7 @@ var ts; function parenthesizeForAccess(expr) { // When diagnosing whether the expression needs parentheses, the decision should be based // on the innermost expression in a chain of nested type assertions. - while (expr.kind === 169 /* TypeAssertionExpression */ || expr.kind === 187 /* AsExpression */) { + while (expr.kind === 171 /* TypeAssertionExpression */ || expr.kind === 189 /* AsExpression */) { expr = expr.expression; } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary @@ -30281,11 +31126,11 @@ var ts; // 1.x -> not the same as (1).x // if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 167 /* NewExpression */ && + expr.kind !== 169 /* NewExpression */ && expr.kind !== 8 /* NumericLiteral */) { return expr; } - var node = ts.createSynthesizedNode(170 /* ParenthesizedExpression */); + var node = ts.createSynthesizedNode(172 /* ParenthesizedExpression */); node.expression = expr; return node; } @@ -30320,7 +31165,7 @@ var ts; // Return true if identifier resolves to an exported member of a namespace function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 246 /* SourceFile */; + return container && container.kind !== 248 /* SourceFile */; } function emitShorthandPropertyAssignment(node) { // The name property of a short-hand property assignment is considered an expression position, so here @@ -30340,13 +31185,17 @@ var ts; write(": "); emit(node.name); } + if (languageVersion >= 2 /* ES6 */ && node.objectAssignmentInitializer) { + write(" = "); + emit(node.objectAssignmentInitializer); + } } function tryEmitConstantValue(node) { var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 164 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 166 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -30357,7 +31206,7 @@ var ts; if (compilerOptions.isolatedModules) { return undefined; } - return node.kind === 164 /* PropertyAccessExpression */ || node.kind === 165 /* ElementAccessExpression */ + return node.kind === 166 /* PropertyAccessExpression */ || node.kind === 167 /* ElementAccessExpression */ ? resolver.getConstantValue(node) : undefined; } @@ -30418,7 +31267,7 @@ var ts; emit(node.right); } function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 67 /* Identifier */) { + if (node.left.kind === 69 /* Identifier */) { emitEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -30438,7 +31287,7 @@ var ts; } function emitEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: if (useFallback) { write("typeof "); emitExpressionIdentifier(node); @@ -30446,7 +31295,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 133 /* QualifiedName */: + case 135 /* QualifiedName */: emitQualifiedNameAsExpression(node, useFallback); break; } @@ -30461,16 +31310,16 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 183 /* SpreadElementExpression */; }); + return ts.forEach(elements, function (e) { return e.kind === 185 /* SpreadElementExpression */; }); } function skipParentheses(node) { - while (node.kind === 170 /* ParenthesizedExpression */ || node.kind === 169 /* TypeAssertionExpression */ || node.kind === 187 /* AsExpression */) { + while (node.kind === 172 /* ParenthesizedExpression */ || node.kind === 171 /* TypeAssertionExpression */ || node.kind === 189 /* AsExpression */) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 67 /* Identifier */ || node.kind === 95 /* ThisKeyword */ || node.kind === 93 /* SuperKeyword */) { + if (node.kind === 69 /* Identifier */ || node.kind === 97 /* ThisKeyword */ || node.kind === 95 /* SuperKeyword */) { emit(node); return node; } @@ -30485,20 +31334,20 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 164 /* PropertyAccessExpression */) { + if (expr.kind === 166 /* PropertyAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 165 /* ElementAccessExpression */) { + else if (expr.kind === 167 /* ElementAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 93 /* SuperKeyword */) { + else if (expr.kind === 95 /* SuperKeyword */) { target = expr; write("_super"); } @@ -30507,7 +31356,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 93 /* SuperKeyword */) { + if (target.kind === 95 /* SuperKeyword */) { // Calls of form super(...) and super.foo(...) emitThis(target); } @@ -30530,13 +31379,13 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 93 /* SuperKeyword */) { + if (node.expression.kind === 95 /* SuperKeyword */) { emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 164 /* PropertyAccessExpression */ && node.expression.expression.kind === 93 /* SuperKeyword */; + superCall = node.expression.kind === 166 /* PropertyAccessExpression */ && node.expression.expression.kind === 95 /* SuperKeyword */; } if (superCall && languageVersion < 2 /* ES6 */) { write(".call("); @@ -30605,12 +31454,12 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172 /* ArrowFunction */) { - if (node.expression.kind === 169 /* TypeAssertionExpression */ || node.expression.kind === 187 /* AsExpression */) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 174 /* ArrowFunction */) { + if (node.expression.kind === 171 /* TypeAssertionExpression */ || node.expression.kind === 189 /* AsExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind === 169 /* TypeAssertionExpression */ || operand.kind === 187 /* AsExpression */) { + while (operand.kind === 171 /* TypeAssertionExpression */ || operand.kind === 189 /* AsExpression */) { operand = operand.expression; } // We have an expression of the form: (SubExpr) @@ -30621,15 +31470,15 @@ var ts; // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() // new (A()) should be emitted as new (A()) and not new A() // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () - if (operand.kind !== 177 /* PrefixUnaryExpression */ && - operand.kind !== 175 /* VoidExpression */ && - operand.kind !== 174 /* TypeOfExpression */ && - operand.kind !== 173 /* DeleteExpression */ && - operand.kind !== 178 /* PostfixUnaryExpression */ && - operand.kind !== 167 /* NewExpression */ && - !(operand.kind === 166 /* CallExpression */ && node.parent.kind === 167 /* NewExpression */) && - !(operand.kind === 171 /* FunctionExpression */ && node.parent.kind === 166 /* CallExpression */) && - !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 164 /* PropertyAccessExpression */)) { + if (operand.kind !== 179 /* PrefixUnaryExpression */ && + operand.kind !== 177 /* VoidExpression */ && + operand.kind !== 176 /* TypeOfExpression */ && + operand.kind !== 175 /* DeleteExpression */ && + operand.kind !== 180 /* PostfixUnaryExpression */ && + operand.kind !== 169 /* NewExpression */ && + !(operand.kind === 168 /* CallExpression */ && node.parent.kind === 169 /* NewExpression */) && + !(operand.kind === 173 /* FunctionExpression */ && node.parent.kind === 168 /* CallExpression */) && + !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 166 /* PropertyAccessExpression */)) { emit(operand); return; } @@ -30640,25 +31489,25 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(76 /* DeleteKeyword */)); + write(ts.tokenToString(78 /* DeleteKeyword */)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(101 /* VoidKeyword */)); + write(ts.tokenToString(103 /* VoidKeyword */)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(99 /* TypeOfKeyword */)); + write(ts.tokenToString(101 /* TypeOfKeyword */)); write(" "); emit(node.expression); } function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 67 /* Identifier */ || ts.nodeIsSynthesized(node)) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 69 /* Identifier */ || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 /* VariableDeclaration */ || node.parent.kind === 161 /* BindingElement */); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 211 /* VariableDeclaration */ || node.parent.kind === 163 /* BindingElement */); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -30688,12 +31537,12 @@ var ts; // the resulting expression a prefix increment operation. And in the second, it will make the resulting // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. - if (node.operand.kind === 177 /* PrefixUnaryExpression */) { + if (node.operand.kind === 179 /* PrefixUnaryExpression */) { var operand = node.operand; - if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 40 /* PlusPlusToken */)) { + if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 41 /* PlusPlusToken */)) { write(" "); } - else if (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 41 /* MinusMinusToken */)) { + else if (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 42 /* MinusMinusToken */)) { write(" "); } } @@ -30713,7 +31562,7 @@ var ts; write("\", "); write(ts.tokenToString(node.operator)); emit(node.operand); - if (node.operator === 40 /* PlusPlusToken */) { + if (node.operator === 41 /* PlusPlusToken */) { write(") - 1)"); } else { @@ -30744,10 +31593,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 246 /* SourceFile */) { + if (current.kind === 248 /* SourceFile */) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 217 /* ModuleBlock */) { + else if (ts.isFunctionLike(current) || current.kind === 219 /* ModuleBlock */) { return false; } else { @@ -30755,14 +31604,69 @@ var ts; } } } + /** + * Emit ES7 exponentiation operator downlevel using Math.pow + * @param node a binary expression node containing exponentiationOperator (**, **=) + */ + function emitExponentiationOperator(node) { + var leftHandSideExpression = node.left; + if (node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { + var synthesizedLHS; + var shouldEmitParentheses = false; + if (ts.isElementAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(167 /* ElementAccessExpression */, /*startsOnNewLine*/ false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldEmitCommaBeforeAssignment*/ false); + synthesizedLHS.expression = identifier; + if (leftHandSideExpression.argumentExpression.kind !== 8 /* NumericLiteral */ && + leftHandSideExpression.argumentExpression.kind !== 9 /* StringLiteral */) { + var tempArgumentExpression = createAndRecordTempVariable(268435456 /* _i */); + synthesizedLHS.argumentExpression = tempArgumentExpression; + emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, /*shouldEmitCommaBeforeAssignment*/ true); + } + else { + synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; + } + write(", "); + } + else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(166 /* PropertyAccessExpression */, /*startsOnNewLine*/ false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldemitCommaBeforeAssignment*/ false); + synthesizedLHS.expression = identifier; + synthesizedLHS.dotToken = leftHandSideExpression.dotToken; + synthesizedLHS.name = leftHandSideExpression.name; + write(", "); + } + emit(synthesizedLHS || leftHandSideExpression); + write(" = "); + write("Math.pow("); + emit(synthesizedLHS || leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + if (shouldEmitParentheses) { + write(")"); + } + } + else { + write("Math.pow("); + emit(leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + } + } function emitBinaryExpression(node) { - if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 55 /* EqualsToken */ && - (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 193 /* ExpressionStatement */); + if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 56 /* EqualsToken */ && + (node.left.kind === 165 /* ObjectLiteralExpression */ || node.left.kind === 164 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 195 /* ExpressionStatement */); } else { - var exportChanged = node.operatorToken.kind >= 55 /* FirstAssignment */ && - node.operatorToken.kind <= 66 /* LastAssignment */ && + var exportChanged = node.operatorToken.kind >= 56 /* FirstAssignment */ && + node.operatorToken.kind <= 68 /* LastAssignment */ && isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); if (exportChanged) { // emit assignment 'x y' as 'exports("x", x y)' @@ -30770,12 +31674,25 @@ var ts; emitNodeWithoutSourceMap(node.left); write("\", "); } - emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 /* CommaToken */ ? " " : undefined); - write(ts.tokenToString(node.operatorToken.kind)); - var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); - emit(node.right); - decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + if (node.operatorToken.kind === 38 /* AsteriskAsteriskToken */ || node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { + // Downleveled emit exponentiation operator using Math.pow + emitExponentiationOperator(node); + } + else { + emit(node.left); + // Add indentation before emit the operator if the operator is on different line + // For example: + // 3 + // + 2; + // emitted as + // 3 + // + 2; + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 /* CommaToken */ ? " " : undefined); + write(ts.tokenToString(node.operatorToken.kind)); + var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); + emit(node.right); + decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + } if (exportChanged) { write(")"); } @@ -30810,7 +31727,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 190 /* Block */) { + if (node && node.kind === 192 /* Block */) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -30825,12 +31742,12 @@ var ts; emitToken(15 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 217 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 216 /* ModuleDeclaration */); + if (node.kind === 219 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 218 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 217 /* ModuleBlock */) { + if (node.kind === 219 /* ModuleBlock */) { emitTempDeclarations(/*newLine*/ true); } decreaseIndent(); @@ -30839,7 +31756,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 190 /* Block */) { + if (node.kind === 192 /* Block */) { write(" "); emit(node); } @@ -30851,11 +31768,11 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 172 /* ArrowFunction */); + emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 174 /* ArrowFunction */); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(86 /* IfKeyword */, node.pos); + var endPos = emitToken(88 /* IfKeyword */, node.pos); write(" "); endPos = emitToken(17 /* OpenParenToken */, endPos); emit(node.expression); @@ -30863,8 +31780,8 @@ var ts; emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(78 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 194 /* IfStatement */) { + emitToken(80 /* ElseKeyword */, node.thenStatement.end); + if (node.elseStatement.kind === 196 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -30876,7 +31793,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 190 /* Block */) { + if (node.statement.kind === 192 /* Block */) { write(" "); } else { @@ -30902,13 +31819,13 @@ var ts; // variables in variable declaration list were already hoisted return false; } - var tokenKind = 100 /* VarKeyword */; + var tokenKind = 102 /* VarKeyword */; if (decl && languageVersion >= 2 /* ES6 */) { if (ts.isLet(decl)) { - tokenKind = 106 /* LetKeyword */; + tokenKind = 108 /* LetKeyword */; } else if (ts.isConst(decl)) { - tokenKind = 72 /* ConstKeyword */; + tokenKind = 74 /* ConstKeyword */; } } if (startPos !== undefined) { @@ -30917,13 +31834,13 @@ var ts; } else { switch (tokenKind) { - case 100 /* VarKeyword */: + case 102 /* VarKeyword */: write("var "); break; - case 106 /* LetKeyword */: + case 108 /* LetKeyword */: write("let "); break; - case 72 /* ConstKeyword */: + case 74 /* ConstKeyword */: write("const "); break; } @@ -30948,10 +31865,10 @@ var ts; return started; } function emitForStatement(node) { - var endPos = emitToken(84 /* ForKeyword */, node.pos); + var endPos = emitToken(86 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(17 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 212 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -30972,13 +31889,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 199 /* ForOfStatement */) { + if (languageVersion < 2 /* ES6 */ && node.kind === 201 /* ForOfStatement */) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(84 /* ForKeyword */, node.pos); + var endPos = emitToken(86 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(17 /* OpenParenToken */, endPos); - if (node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer.kind === 212 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -30988,7 +31905,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 198 /* ForInStatement */) { + if (node.kind === 200 /* ForInStatement */) { write(" in "); } else { @@ -31019,7 +31936,7 @@ var ts; // 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(84 /* ForKeyword */, node.pos); + var endPos = emitToken(86 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(17 /* OpenParenToken */, endPos); // Do not emit the LHS let declaration yet, because it might contain destructuring. @@ -31030,7 +31947,7 @@ var ts; // for (let v of arr) { } // // we don't want to emit a temporary variable for the RHS, just use it directly. - var rhsIsIdentifier = node.expression.kind === 67 /* Identifier */; + var rhsIsIdentifier = node.expression.kind === 69 /* Identifier */; var counter = createTempVariable(268435456 /* _i */); var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); // This is the let keyword for the counter and rhsReference. The let keyword for @@ -31073,7 +31990,7 @@ var ts; // let v = _a[_i]; var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer.kind === 212 /* VariableDeclarationList */) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -31102,8 +32019,8 @@ var ts; else { // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. - var assignmentExpression = createBinaryExpression(node.initializer, 55 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); - if (node.initializer.kind === 162 /* ArrayLiteralExpression */ || node.initializer.kind === 163 /* ObjectLiteralExpression */) { + var assignmentExpression = createBinaryExpression(node.initializer, 56 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); + if (node.initializer.kind === 164 /* ArrayLiteralExpression */ || node.initializer.kind === 165 /* ObjectLiteralExpression */) { // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined); @@ -31114,7 +32031,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 190 /* Block */) { + if (node.statement.kind === 192 /* Block */) { emitLines(node.statement.statements); } else { @@ -31126,12 +32043,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 203 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(92 /* ReturnKeyword */, node.pos); + emitToken(94 /* ReturnKeyword */, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -31142,7 +32059,7 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(94 /* SwitchKeyword */, node.pos); + var endPos = emitToken(96 /* SwitchKeyword */, node.pos); write(" "); emitToken(17 /* OpenParenToken */, endPos); emit(node.expression); @@ -31171,7 +32088,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 239 /* CaseClause */) { + if (node.kind === 241 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -31206,7 +32123,7 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(70 /* CatchKeyword */, node.pos); + var endPos = emitToken(72 /* CatchKeyword */, node.pos); write(" "); emitToken(17 /* OpenParenToken */, endPos); emit(node.variableDeclaration); @@ -31215,7 +32132,7 @@ var ts; emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(74 /* DebuggerKeyword */, node.pos); + emitToken(76 /* DebuggerKeyword */, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -31226,7 +32143,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 216 /* ModuleDeclaration */); + } while (node && node.kind !== 218 /* ModuleDeclaration */); return node; } function emitContainingModuleName(node) { @@ -31241,7 +32158,7 @@ var ts; write(getGeneratedNameForNode(container)); write("."); } - else if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { + else if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { write("exports."); } } @@ -31251,15 +32168,15 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(8 /* NumericLiteral */); zero.text = "0"; - var result = ts.createSynthesizedNode(175 /* VoidExpression */); + var result = ts.createSynthesizedNode(177 /* VoidExpression */); result.expression = zero; return result; } function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 246 /* SourceFile */) { - ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 225 /* ExportAssignment */); + if (node.parent.kind === 248 /* SourceFile */) { + ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 227 /* ExportAssignment */); // only allow export default at a source file level - if (compilerOptions.module === 1 /* CommonJS */ || compilerOptions.module === 2 /* AMD */ || compilerOptions.module === 3 /* UMD */) { + if (modulekind === 1 /* CommonJS */ || modulekind === 2 /* AMD */ || modulekind === 3 /* UMD */) { if (!currentSourceFile.symbol.exports["___esModule"]) { if (languageVersion === 1 /* ES5 */) { // default value of configurable, enumerable, writable are `false`. @@ -31279,7 +32196,7 @@ var ts; writeLine(); emitStart(node); // emit call to exporter only for top level nodes - if (compilerOptions.module === 4 /* System */ && node.parent === currentSourceFile) { + if (modulekind === 4 /* System */ && node.parent === currentSourceFile) { // emit export default as // export("default", ) write(exportFunctionForFile + "(\""); @@ -31314,7 +32231,7 @@ var ts; } } function emitExportMemberAssignments(name) { - if (compilerOptions.module === 4 /* System */) { + if (modulekind === 4 /* System */) { return; } if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { @@ -31333,7 +32250,7 @@ var ts; } } function emitExportSpecifierInSystemModule(specifier) { - ts.Debug.assert(compilerOptions.module === 4 /* System */); + ts.Debug.assert(modulekind === 4 /* System */); if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { return; } @@ -31347,6 +32264,49 @@ var ts; emitEnd(specifier.name); write(";"); } + /** + * Emit an assignment to a given identifier, 'name', with a given expression, 'value'. + * @param name an identifier as a left-hand-side operand of the assignment + * @param value an expression as a right-hand-side operand of the assignment + * @param shouldEmitCommaBeforeAssignment a boolean indicating whether to prefix an assignment with comma + */ + function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { + if (shouldEmitCommaBeforeAssignment) { + write(", "); + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(name); + write("\", "); + } + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 211 /* VariableDeclaration */ || name.parent.kind === 163 /* BindingElement */); + if (isVariableDeclarationOrBindingElement) { + emitModuleMemberName(name.parent); + } + else { + emit(name); + } + write(" = "); + emit(value); + if (exportChanged) { + write(")"); + } + } + /** + * Create temporary variable, emit an assignment of the variable the given expression + * @param expression an expression to assign to the newly created temporary variable + * @param canDefineTempVariablesInPlace a boolean indicating whether you can define the temporary variable at an assignment location + * @param shouldEmitCommaBeforeAssignment a boolean indicating whether an assignment should prefix with comma + */ + function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { + var identifier = createTempVariable(0 /* Auto */); + if (!canDefineTempVariablesInPlace) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); + return identifier; + } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; // An exported declaration is actually emitted as an assignment (to a property on the module object), so @@ -31354,44 +32314,21 @@ var ts; // Also temporary variables should be explicitly allocated for source level declarations when module target is system // because actual variable declarations are hoisted var canDefineTempVariablesInPlace = false; - if (root.kind === 209 /* VariableDeclaration */) { + if (root.kind === 211 /* VariableDeclaration */) { var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 136 /* Parameter */) { + else if (root.kind === 138 /* Parameter */) { canDefineTempVariablesInPlace = true; } - if (root.kind === 179 /* BinaryExpression */) { + if (root.kind === 181 /* BinaryExpression */) { emitAssignmentExpression(root); } else { ts.Debug.assert(!isAssignmentExpressionStatement); emitBindingElement(root, value); } - function emitAssignment(name, value) { - if (emitCount++) { - write(", "); - } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 /* VariableDeclaration */ || name.parent.kind === 161 /* BindingElement */); - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(name); - write("\", "); - } - if (isVariableDeclarationOrBindingElement) { - emitModuleMemberName(name.parent); - } - else { - emit(name); - } - write(" = "); - emit(value); - if (exportChanged) { - write(")"); - } - } /** * Ensures that there exists a declared identifier whose value holds the given expression. * This function is useful to ensure that the expression's value can be read from in subsequent expressions. @@ -31402,14 +32339,11 @@ var ts; * false if it is necessary to always emit an identifier. */ function ensureIdentifier(expr, reuseIdentifierExpressions) { - if (expr.kind === 67 /* Identifier */ && reuseIdentifierExpressions) { + if (expr.kind === 69 /* Identifier */ && reuseIdentifierExpressions) { return expr; } - var identifier = createTempVariable(0 /* Auto */); - if (!canDefineTempVariablesInPlace) { - recordTempDeclaration(identifier); - } - emitAssignment(identifier, expr); + var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); + emitCount++; return identifier; } function createDefaultValueCheck(value, defaultValue) { @@ -31417,18 +32351,18 @@ var ts; // we need to generate a temporary variable value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(179 /* BinaryExpression */); + var equals = ts.createSynthesizedNode(181 /* BinaryExpression */); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(32 /* EqualsEqualsEqualsToken */); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(180 /* ConditionalExpression */); + var cond = ts.createSynthesizedNode(182 /* ConditionalExpression */); cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(52 /* QuestionToken */); + cond.questionToken = ts.createSynthesizedNode(53 /* QuestionToken */); cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(53 /* ColonToken */); + cond.colonToken = ts.createSynthesizedNode(54 /* ColonToken */); cond.whenFalse = whenFalse; return cond; } @@ -31442,14 +32376,14 @@ var ts; // otherwise occur when the identifier is emitted. var syntheticName = ts.createSynthesizedNode(propName.kind); syntheticName.text = propName.text; - if (syntheticName.kind !== 67 /* Identifier */) { + if (syntheticName.kind !== 69 /* Identifier */) { return createElementAccessExpression(object, syntheticName); } return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(166 /* CallExpression */); - var sliceIdentifier = ts.createSynthesizedNode(67 /* Identifier */); + var call = ts.createSynthesizedNode(168 /* CallExpression */); + var sliceIdentifier = ts.createSynthesizedNode(69 /* Identifier */); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); call.arguments = ts.createSynthesizedNodeArray(); @@ -31465,9 +32399,10 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) { + if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { var propName = p.name; - emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); + var target_1 = p.kind === 246 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; + emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); } } } @@ -31480,8 +32415,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 185 /* OmittedExpression */) { - if (e.kind !== 183 /* SpreadElementExpression */) { + if (e.kind !== 187 /* OmittedExpression */) { + if (e.kind !== 185 /* SpreadElementExpression */) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -31491,18 +32426,25 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) { + if (target.kind === 246 /* ShorthandPropertyAssignment */) { + if (target.objectAssignmentInitializer) { + value = createDefaultValueCheck(value, target.objectAssignmentInitializer); + } + target = target.name; + } + else if (target.kind === 181 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 163 /* ObjectLiteralExpression */) { + if (target.kind === 165 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 162 /* ArrayLiteralExpression */) { + else if (target.kind === 164 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value); } else { - emitAssignment(target, value); + emitAssignment(target, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0); + emitCount++; } } function emitAssignmentExpression(root) { @@ -31515,14 +32457,14 @@ var ts; emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 170 /* ParenthesizedExpression */) { + if (root.parent.kind !== 172 /* ParenthesizedExpression */) { write("("); } value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 170 /* ParenthesizedExpression */) { + if (root.parent.kind !== 172 /* ParenthesizedExpression */) { write(")"); } } @@ -31549,12 +32491,12 @@ var ts; } for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (pattern.kind === 159 /* ObjectBindingPattern */) { + if (pattern.kind === 161 /* ObjectBindingPattern */) { // Rewrite element to a declaration with an initializer that fetches property var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 185 /* OmittedExpression */) { + else if (element.kind !== 187 /* OmittedExpression */) { if (!element.dotDotDotToken) { // Rewrite element to a declaration that accesses array element at index i emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); @@ -31566,7 +32508,8 @@ var ts; } } else { - emitAssignment(target.name, value); + emitAssignment(target.name, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0); + emitCount++; } } } @@ -31593,8 +32536,8 @@ var ts; (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isUninitializedLet && - node.parent.parent.kind !== 198 /* ForInStatement */ && - node.parent.parent.kind !== 199 /* ForOfStatement */) { + node.parent.parent.kind !== 200 /* ForInStatement */ && + node.parent.parent.kind !== 201 /* ForOfStatement */) { initializer = createVoidZero(); } } @@ -31612,11 +32555,11 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 185 /* OmittedExpression */) { + if (node.kind === 187 /* OmittedExpression */) { return; } var name = node.name; - if (name.kind === 67 /* Identifier */) { + if (name.kind === 69 /* Identifier */) { emitExportMemberAssignments(name); } else if (ts.isBindingPattern(name)) { @@ -31624,15 +32567,15 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 209 /* VariableDeclaration */ && node.parent.kind !== 161 /* BindingElement */)) { + if (!node.parent || (node.parent.kind !== 211 /* VariableDeclaration */ && node.parent.kind !== 163 /* BindingElement */)) { return 0; } return ts.getCombinedNodeFlags(node.parent); } function isES6ExportedDeclaration(node) { return !!(node.flags & 1 /* Export */) && - languageVersion >= 2 /* ES6 */ && - node.parent.kind === 246 /* SourceFile */; + modulekind === 5 /* ES6 */ && + node.parent.kind === 248 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -31656,7 +32599,7 @@ var ts; write(";"); } } - if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile) { + if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); } } @@ -31683,12 +32626,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2 /* ES6 */) { if (ts.isBindingPattern(node.name)) { - var name_23 = createTempVariable(0 /* Auto */); + var name_24 = createTempVariable(0 /* Auto */); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_23); - emit(name_23); + tempParameters.push(name_24); + emit(name_24); } else { emit(node.name); @@ -31793,12 +32736,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 143 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 145 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 172 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + return node.kind === 174 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; } function emitDeclarationName(node) { if (node.name) { @@ -31809,11 +32752,11 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 171 /* FunctionExpression */) { + if (node.kind === 173 /* FunctionExpression */) { // Emit name if one is present return !!node.name; } - if (node.kind === 211 /* FunctionDeclaration */) { + if (node.kind === 213 /* FunctionDeclaration */) { // Emit name if one is present, or emit generated name in down-level case (for export default case) return !!node.name || languageVersion < 2 /* ES6 */; } @@ -31824,9 +32767,9 @@ var ts; } // TODO (yuisu) : we should not have special cases to condition emitting comments // but have one place to fix check for these conditions. - if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */ && - node.parent && node.parent.kind !== 243 /* PropertyAssignment */ && - node.parent.kind !== 166 /* CallExpression */) { + if (node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */ && + node.parent && node.parent.kind !== 245 /* PropertyAssignment */ && + node.parent.kind !== 168 /* CallExpression */) { // 1. Methods will emit the comments as part of emitting method declaration // 2. If the function is a property of object literal, emitting leading-comments // is done by emitNodeWithoutSourceMap which then call this function. @@ -31860,11 +32803,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 /* ES6 */ && node.kind === 211 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { + if (modulekind !== 5 /* ES6 */ && node.kind === 213 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } emitEnd(node); - if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) { + if (node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */) { emitTrailingComments(node); } } @@ -31897,7 +32840,7 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 172 /* ArrowFunction */; + var isArrowFunction = node.kind === 174 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* CaptureArguments */) !== 0; var args; // An async function is emit as an outer function that calls an inner @@ -32018,7 +32961,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 190 /* Block */) { + if (node.body.kind === 192 /* Block */) { emitBlockFunctionBody(node, node.body); } else { @@ -32073,10 +33016,10 @@ var ts; write(" "); // Unwrap all type assertions. var current = body; - while (current.kind === 169 /* TypeAssertionExpression */) { + while (current.kind === 171 /* TypeAssertionExpression */) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 163 /* ObjectLiteralExpression */); + emitParenthesizedIf(body, current.kind === 165 /* ObjectLiteralExpression */); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -32152,11 +33095,11 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 193 /* ExpressionStatement */) { + if (statement && statement.kind === 195 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 166 /* CallExpression */) { + if (expr && expr.kind === 168 /* CallExpression */) { var func = expr.expression; - if (func && func.kind === 93 /* SuperKeyword */) { + if (func && func.kind === 95 /* SuperKeyword */) { return statement; } } @@ -32188,7 +33131,7 @@ var ts; emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 134 /* ComputedPropertyName */) { + else if (memberName.kind === 136 /* ComputedPropertyName */) { emitComputedPropertyName(memberName); } else { @@ -32200,7 +33143,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 139 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + if (member.kind === 141 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { properties.push(member); } } @@ -32240,11 +33183,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 189 /* SemicolonClassElement */) { + if (member.kind === 191 /* SemicolonClassElement */) { writeLine(); write(";"); } - else if (member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) { + else if (member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) { if (!member.body) { return emitCommentsOnNotEmittedNode(member); } @@ -32261,7 +33204,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */) { + else if (member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -32311,22 +33254,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) && !member.body) { + if ((member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) && !member.body) { emitCommentsOnNotEmittedNode(member); } - else if (member.kind === 141 /* MethodDeclaration */ || - member.kind === 143 /* GetAccessor */ || - member.kind === 144 /* SetAccessor */) { + else if (member.kind === 143 /* MethodDeclaration */ || + member.kind === 145 /* GetAccessor */ || + member.kind === 146 /* SetAccessor */) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128 /* Static */) { write("static "); } - if (member.kind === 143 /* GetAccessor */) { + if (member.kind === 145 /* GetAccessor */) { write("get "); } - else if (member.kind === 144 /* SetAccessor */) { + else if (member.kind === 146 /* SetAccessor */) { write("set "); } if (member.asteriskToken) { @@ -32337,7 +33280,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 189 /* SemicolonClassElement */) { + else if (member.kind === 191 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -32362,11 +33305,11 @@ var ts; var hasInstancePropertyWithInitializer = false; // Emit the constructor overload pinned comments ts.forEach(node.members, function (member) { - if (member.kind === 142 /* Constructor */ && !member.body) { + if (member.kind === 144 /* Constructor */ && !member.body) { emitCommentsOnNotEmittedNode(member); } // Check if there is any non-static property assignment - if (member.kind === 139 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + if (member.kind === 141 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -32476,10 +33419,13 @@ var ts; else { emitClassLikeDeclarationForES6AndHigher(node); } + if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 212 /* ClassDeclaration */) { + if (node.kind === 214 /* ClassDeclaration */) { if (thisNodeIsDecorated) { // To preserve the correct runtime semantics when decorators are applied to the class, // the emit needs to follow one of the following rules: @@ -32493,7 +33439,6 @@ var ts; // // let C = class { // }; - // Object.defineProperty(C, "name", { value: "C", configurable: true }); // C = __decorate([dec], C); // // * For an exported class declaration: @@ -32505,7 +33450,6 @@ var ts; // // export let C = class { // }; - // Object.defineProperty(C, "name", { value: "C", configurable: true }); // C = __decorate([dec], C); // // * For a default export of a class declaration with a name: @@ -32517,7 +33461,6 @@ var ts; // // let C = class { // } - // Object.defineProperty(C, "name", { value: "C", configurable: true }); // C = __decorate([dec], C); // export default C; // @@ -32559,7 +33502,7 @@ var ts; // This keeps the expression as an expression, while ensuring that the static parts // of it have been initialized by the time it is used. var staticProperties = getInitializedProperties(node, /*static:*/ true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184 /* ClassExpression */; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 186 /* ClassExpression */; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0 /* Auto */); @@ -32569,8 +33512,10 @@ var ts; write(" = "); } write("class"); - // check if this is an "export default class" as it may not have a name. Do not emit the name if the class is decorated. - if ((node.name || !(node.flags & 1024 /* Default */)) && !thisNodeIsDecorated) { + // emit name if + // - node has a name + // - this is default export with static initializers + if ((node.name || (node.flags & 1024 /* Default */ && staticProperties.length > 0)) && !thisNodeIsDecorated) { write(" "); emitDeclarationName(node); } @@ -32643,7 +33588,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 212 /* ClassDeclaration */) { + if (node.kind === 214 /* ClassDeclaration */) { // source file level classes in system modules are hoisted so 'var's for them are already defined if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); @@ -32702,16 +33647,13 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 212 /* ClassDeclaration */) { + if (node.kind === 214 /* ClassDeclaration */) { write(";"); } emitEnd(node); - if (node.kind === 212 /* ClassDeclaration */) { + if (node.kind === 214 /* ClassDeclaration */) { emitExportMemberAssignment(node); } - if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } } function emitClassMemberPrefix(node, member) { emitDeclarationName(node); @@ -32798,7 +33740,7 @@ var ts; else { decorators = member.decorators; // we only decorate the parameters here if this is a method - if (member.kind === 141 /* MethodDeclaration */) { + if (member.kind === 143 /* MethodDeclaration */) { functionLikeMember = member; } } @@ -32812,21 +33754,19 @@ var ts; // // The emit for a method is: // - // Object.defineProperty(C.prototype, "method", - // __decorate([ - // dec, - // __param(0, dec2), - // __metadata("design:type", Function), - // __metadata("design:paramtypes", [Object]), - // __metadata("design:returntype", void 0) - // ], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); + // __decorate([ + // dec, + // __param(0, dec2), + // __metadata("design:type", Function), + // __metadata("design:paramtypes", [Object]), + // __metadata("design:returntype", void 0) + // ], C.prototype, "method", undefined); // // The emit for an accessor is: // - // Object.defineProperty(C.prototype, "accessor", - // __decorate([ - // dec - // ], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor"))); + // __decorate([ + // dec + // ], C.prototype, "accessor", undefined); // // The emit for a property is: // @@ -32836,17 +33776,6 @@ var ts; // writeLine(); emitStart(member); - if (member.kind !== 139 /* PropertyDeclaration */) { - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(","); - increaseIndent(); - writeLine(); - } write("__decorate(["); increaseIndent(); writeLine(); @@ -32866,15 +33795,17 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 139 /* PropertyDeclaration */) { - write(", Object.getOwnPropertyDescriptor("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write("))"); - decreaseIndent(); + if (languageVersion > 0 /* ES3 */) { + if (member.kind !== 141 /* PropertyDeclaration */) { + // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly. + // We have this extra argument here so that we can inject an explicit property descriptor at a later date. + write(", null"); + } + else { + // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it + // should not invoke `Object.getOwnPropertyDescriptor`. + write(", void 0"); + } } write(");"); emitEnd(member); @@ -32908,10 +33839,10 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 139 /* PropertyDeclaration */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 141 /* PropertyDeclaration */: return true; } return false; @@ -32921,7 +33852,7 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 141 /* MethodDeclaration */: + case 143 /* MethodDeclaration */: return true; } return false; @@ -32931,9 +33862,9 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 212 /* ClassDeclaration */: - case 141 /* MethodDeclaration */: - case 144 /* SetAccessor */: + case 214 /* ClassDeclaration */: + case 143 /* MethodDeclaration */: + case 146 /* SetAccessor */: return true; } return false; @@ -32951,19 +33882,19 @@ var ts; // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: write("Function"); return; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: emitSerializedTypeNode(node.type); return; - case 136 /* Parameter */: + case 138 /* Parameter */: emitSerializedTypeNode(node.type); return; - case 143 /* GetAccessor */: + case 145 /* GetAccessor */: emitSerializedTypeNode(node.type); return; - case 144 /* SetAccessor */: + case 146 /* SetAccessor */: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -32976,42 +33907,42 @@ var ts; function emitSerializedTypeNode(node) { if (node) { switch (node.kind) { - case 101 /* VoidKeyword */: + case 103 /* VoidKeyword */: write("void 0"); return; - case 158 /* ParenthesizedType */: + case 160 /* ParenthesizedType */: emitSerializedTypeNode(node.type); return; - case 150 /* FunctionType */: - case 151 /* ConstructorType */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: write("Function"); return; - case 154 /* ArrayType */: - case 155 /* TupleType */: + case 156 /* ArrayType */: + case 157 /* TupleType */: write("Array"); return; - case 148 /* TypePredicate */: - case 118 /* BooleanKeyword */: + case 150 /* TypePredicate */: + case 120 /* BooleanKeyword */: write("Boolean"); return; - case 128 /* StringKeyword */: + case 130 /* StringKeyword */: case 9 /* StringLiteral */: write("String"); return; - case 126 /* NumberKeyword */: + case 128 /* NumberKeyword */: write("Number"); return; - case 129 /* SymbolKeyword */: + case 131 /* SymbolKeyword */: write("Symbol"); return; - case 149 /* TypeReference */: + case 151 /* TypeReference */: emitSerializedTypeReferenceNode(node); return; - case 152 /* TypeQuery */: - case 153 /* TypeLiteral */: - case 156 /* UnionType */: - case 157 /* IntersectionType */: - case 115 /* AnyKeyword */: + case 154 /* TypeQuery */: + case 155 /* TypeLiteral */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: + case 117 /* AnyKeyword */: break; default: ts.Debug.fail("Cannot serialize unexpected type node."); @@ -33085,7 +34016,7 @@ var ts; // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { var valueDeclaration; - if (node.kind === 212 /* ClassDeclaration */) { + if (node.kind === 214 /* ClassDeclaration */) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -33101,10 +34032,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 154 /* ArrayType */) { + if (parameterType.kind === 156 /* ArrayType */) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 149 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 151 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -33222,8 +34153,8 @@ var ts; emitEnd(node); write(";"); } - if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile) { - if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) { + if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { + if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { // write the call to exporter for enum writeLine(); write(exportFunctionForFile + "(\""); @@ -33264,7 +34195,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 218 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -33300,7 +34231,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 217 /* ModuleBlock */) { + if (node.body.kind === 219 /* ModuleBlock */) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -33333,8 +34264,8 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 67 /* Identifier */ && node.parent === currentSourceFile) { - if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 69 /* Identifier */ && node.parent === currentSourceFile) { + if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -33374,16 +34305,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 219 /* ImportEqualsDeclaration */) { + if (node.kind === 221 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 224 /* NamespaceImport */) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 220 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 222 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -33392,7 +34323,7 @@ var ts; ts.forEachChild(node, emitExportImportAssignments); } function emitImportDeclaration(node) { - if (languageVersion < 2 /* ES6 */) { + if (modulekind !== 5 /* ES6 */) { return emitExternalImportDeclaration(node); } // ES6 import @@ -33411,7 +34342,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 224 /* NamespaceImport */) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -33437,9 +34368,9 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 219 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var isExportedImport = node.kind === 221 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (compilerOptions.module !== 2 /* AMD */) { + if (modulekind !== 2 /* AMD */) { emitLeadingComments(node); emitStart(node); if (namespaceDeclaration && !isDefaultImport(node)) { @@ -33456,7 +34387,7 @@ var ts; // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - var isNakedImport = 220 /* ImportDeclaration */ && !node.importClause; + var isNakedImport = 222 /* ImportDeclaration */ && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -33541,14 +34472,14 @@ var ts; } } function emitExportDeclaration(node) { - ts.Debug.assert(compilerOptions.module !== 4 /* System */); - if (languageVersion < 2 /* ES6 */) { + ts.Debug.assert(modulekind !== 4 /* System */); + if (modulekind !== 5 /* ES6 */) { if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { emitStart(node); var generatedName = getGeneratedNameForNode(node); if (node.exportClause) { // export { x, y, ... } from "foo" - if (compilerOptions.module !== 2 /* AMD */) { + if (modulekind !== 2 /* AMD */) { write("var "); write(generatedName); write(" = "); @@ -33576,7 +34507,7 @@ var ts; // export * from "foo" writeLine(); write("__export("); - if (compilerOptions.module !== 2 /* AMD */) { + if (modulekind !== 2 /* AMD */) { emitRequire(ts.getExternalModuleName(node)); } else { @@ -33608,7 +34539,7 @@ var ts; } } function emitExportOrImportSpecifierList(specifiers, shouldEmit) { - ts.Debug.assert(languageVersion >= 2 /* ES6 */); + ts.Debug.assert(modulekind === 5 /* ES6 */); var needsComma = false; for (var _a = 0; _a < specifiers.length; _a++) { var specifier = specifiers[_a]; @@ -33627,14 +34558,14 @@ var ts; } function emitExportAssignment(node) { if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { - if (languageVersion >= 2 /* ES6 */) { + if (modulekind === 5 /* ES6 */) { writeLine(); emitStart(node); write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 211 /* FunctionDeclaration */ && - expression.kind !== 212 /* ClassDeclaration */) { + if (expression.kind !== 213 /* FunctionDeclaration */ && + expression.kind !== 214 /* ClassDeclaration */) { write(";"); } emitEnd(node); @@ -33642,7 +34573,7 @@ var ts; else { writeLine(); emitStart(node); - if (compilerOptions.module === 4 /* System */) { + if (modulekind === 4 /* System */) { write(exportFunctionForFile + "(\"default\","); emit(node.expression); write(")"); @@ -33671,7 +34602,7 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, /*checkChildren*/ true)) { // import "mod" @@ -33681,13 +34612,13 @@ var ts; externalImports.push(node); } break; - case 219 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 230 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + case 221 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 232 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { // import x = require("mod") where x is referenced externalImports.push(node); } break; - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -33703,12 +34634,12 @@ var ts; // export { x, y } for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_24 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier); + var name_25 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_25] || (exportSpecifiers[name_25] = [])).push(specifier); } } break; - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -33734,10 +34665,10 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - if (node.kind === 220 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 222 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 226 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 228 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } @@ -33757,8 +34688,8 @@ var ts; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; // do not create variable declaration for exports and imports that lack import clause - var skipNode = importNode.kind === 226 /* ExportDeclaration */ || - (importNode.kind === 220 /* ImportDeclaration */ && !importNode.importClause); + var skipNode = importNode.kind === 228 /* ExportDeclaration */ || + (importNode.kind === 222 /* ImportDeclaration */ && !importNode.importClause); if (skipNode) { continue; } @@ -33791,7 +34722,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 226 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 228 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -33823,7 +34754,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 226 /* ExportDeclaration */) { + if (externalImport.kind !== 228 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -33871,7 +34802,7 @@ var ts; function writeExportedName(node) { // do not record default exports // they are local to module and never overwritten (explicitly skipped) by star export - if (node.kind !== 67 /* Identifier */ && node.flags & 1024 /* Default */) { + if (node.kind !== 69 /* Identifier */ && node.flags & 1024 /* Default */) { return; } if (started) { @@ -33882,7 +34813,7 @@ var ts; } writeLine(); write("'"); - if (node.kind === 67 /* Identifier */) { + if (node.kind === 69 /* Identifier */) { emitNodeWithCommentsAndWithoutSourcemap(node); } else { @@ -33911,12 +34842,12 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_25 = local.kind === 67 /* Identifier */ + var name_26 = local.kind === 69 /* Identifier */ ? local : local.name; - if (name_25) { + if (name_26) { // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables - var text = ts.unescapeIdentifier(name_25.text); + var text = ts.unescapeIdentifier(name_26.text); if (ts.hasProperty(seen, text)) { continue; } @@ -33927,13 +34858,13 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 212 /* ClassDeclaration */ || local.kind === 216 /* ModuleDeclaration */ || local.kind === 215 /* EnumDeclaration */) { + if (local.kind === 214 /* ClassDeclaration */ || local.kind === 218 /* ModuleDeclaration */ || local.kind === 217 /* EnumDeclaration */) { emitDeclarationName(local); } else { emit(local); } - var flags = ts.getCombinedNodeFlags(local.kind === 67 /* Identifier */ ? local.parent : local); + var flags = ts.getCombinedNodeFlags(local.kind === 69 /* Identifier */ ? local.parent : local); if (flags & 1 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -33961,21 +34892,21 @@ var ts; if (node.flags & 2 /* Ambient */) { return; } - if (node.kind === 211 /* FunctionDeclaration */) { + if (node.kind === 213 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 212 /* ClassDeclaration */) { + if (node.kind === 214 /* ClassDeclaration */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 215 /* EnumDeclaration */) { + if (node.kind === 217 /* EnumDeclaration */) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -33984,7 +34915,7 @@ var ts; } return; } - if (node.kind === 216 /* ModuleDeclaration */) { + if (node.kind === 218 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -33993,17 +34924,17 @@ var ts; } return; } - if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) { + if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) { if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { - var name_26 = node.name; - if (name_26.kind === 67 /* Identifier */) { + var name_27 = node.name; + if (name_27.kind === 69 /* Identifier */) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_26); + hoistedVars.push(name_27); } else { - ts.forEachChild(name_26, visit); + ts.forEachChild(name_27, visit); } } return; @@ -34034,10 +34965,10 @@ var ts; // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 246 /* SourceFile */; + ts.getEnclosingBlockScopeContainer(node).kind === 248 /* SourceFile */; } function isCurrentFileSystemExternalModule() { - return compilerOptions.module === 4 /* System */ && ts.isExternalModule(currentSourceFile); + return modulekind === 4 /* System */ && ts.isExternalModule(currentSourceFile); } function emitSystemModuleBody(node, dependencyGroups, startIndex) { // shape of the body in system modules: @@ -34109,21 +35040,21 @@ var ts; var entry = group[_a]; var importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // fall-through - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== ""); writeLine(); // save import into the local write(importVariableName + " = " + parameterName + ";"); writeLine(); break; - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== ""); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -34180,10 +35111,10 @@ var ts; // - import declarations are not emitted since they are already handled in setters // - export declarations with module specifiers are not emitted since they were already written in setters // - export declarations without module specifiers are emitted preserving the order - case 211 /* FunctionDeclaration */: - case 220 /* ImportDeclaration */: + case 213 /* FunctionDeclaration */: + case 222 /* ImportDeclaration */: continue; - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: if (!statement.moduleSpecifier) { for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { var element = _b[_a]; @@ -34192,7 +35123,7 @@ var ts; } } continue; - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { // - import equals declarations that import external modules are not emitted continue; @@ -34207,7 +35138,7 @@ var ts; writeLine(); write("}"); // execute } - function emitSystemModule(node, startIndex) { + function emitSystemModule(node) { collectExternalModuleInfo(node); // System modules has the following shape // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) @@ -34248,6 +35179,7 @@ var ts; write("], function(" + exportFunctionForFile + ") {"); writeLine(); increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitSystemModuleBody(node, dependencyGroups, startIndex); @@ -34255,18 +35187,7 @@ var ts; writeLine(); write("});"); } - function emitAMDDependencies(node, includeNonAmdDependencies) { - // An AMD define function has the following shape: - // define(id?, dependencies?, factory); - // - // This has the shape of - // define(name, ["module1", "module2"], function (module1Alias) { - // The location of the alias in the parameter list in the factory function needs to - // match the position of the module name in the dependency list. - // - // To ensure this is true in cases of modules with no aliases, e.g.: - // `import "module"` or `` - // we need to add modules without alias names to the end of the dependencies list + function getAMDDependencyNames(node, includeNonAmdDependencies) { // names of modules with corresponding parameter in the factory function var aliasedModuleNames = []; // names of modules with no corresponding parameters in factory function @@ -34299,6 +35220,27 @@ var ts; unaliasedModuleNames.push(externalModuleName); } } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + function emitAMDDependencies(node, includeNonAmdDependencies) { + // An AMD define function has the following shape: + // define(id?, dependencies?, factory); + // + // This has the shape of + // define(name, ["module1", "module2"], function (module1Alias) { + // The location of the alias in the parameter list in the factory function needs to + // match the position of the module name in the dependency list. + // + // To ensure this is true in cases of modules with no aliases, e.g.: + // `import "module"` or `` + // we need to add modules without alias names to the end of the dependencies list + var dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); + emitAMDDependencyList(dependencyNames); + write(", "); + emitAMDFactoryHeader(dependencyNames); + } + function emitAMDDependencyList(_a) { + var aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames; write("[\"require\", \"exports\""); if (aliasedModuleNames.length) { write(", "); @@ -34308,13 +35250,18 @@ var ts; write(", "); write(unaliasedModuleNames.join(", ")); } - write("], function (require, exports"); + write("]"); + } + function emitAMDFactoryHeader(_a) { + var importAliasNames = _a.importAliasNames; + write("function (require, exports"); if (importAliasNames.length) { write(", "); write(importAliasNames.join(", ")); } + write(") {"); } - function emitAMDModule(node, startIndex) { + function emitAMDModule(node) { emitEmitHelpers(node); collectExternalModuleInfo(node); writeLine(); @@ -34323,8 +35270,8 @@ var ts; write("\"" + node.moduleName + "\", "); } emitAMDDependencies(node, /*includeNonAmdDependencies*/ true); - write(") {"); increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -34334,7 +35281,8 @@ var ts; writeLine(); write("});"); } - function emitCommonJSModule(node, startIndex) { + function emitCommonJSModule(node) { + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); @@ -34343,14 +35291,18 @@ var ts; emitTempDeclarations(/*newLine*/ true); emitExportEquals(/*emitAsReturn*/ false); } - function emitUMDModule(node, startIndex) { + function emitUMDModule(node) { emitEmitHelpers(node); collectExternalModuleInfo(node); + var dependencyNames = getAMDDependencyNames(node, /*includeNonAmdDependencies*/ false); // Module is detected first to support Browserify users that load into a browser with an AMD loader - writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); - emitAMDDependencies(node, false); - write(") {"); + writeLines("(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define("); + emitAMDDependencyList(dependencyNames); + write(", factory);"); + writeLines(" }\n})("); + emitAMDFactoryHeader(dependencyNames); increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -34360,11 +35312,12 @@ var ts; writeLine(); write("});"); } - function emitES6Module(node, startIndex) { + function emitES6Module(node) { externalImports = undefined; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -34407,7 +35360,7 @@ var ts; if (ts.isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + "\" + ' ' + \"" : "") + part; + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); } firstNonWhitespace = -1; } @@ -34420,7 +35373,7 @@ var ts; } if (firstNonWhitespace !== -1) { var part = text.substr(firstNonWhitespace); - result = (result ? result + "\" + ' ' + \"" : "") + part; + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); } if (result) { // Replace entities like   @@ -34534,26 +35487,13 @@ var ts; writeLine(); emitShebang(); emitDetachedComments(node); - // emit prologue directives prior to __extends - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - if (languageVersion >= 2 /* ES6 */) { - emitES6Module(node, startIndex); - } - else if (compilerOptions.module === 2 /* AMD */) { - emitAMDModule(node, startIndex); - } - else if (compilerOptions.module === 4 /* System */) { - emitSystemModule(node, startIndex); - } - else if (compilerOptions.module === 3 /* UMD */) { - emitUMDModule(node, startIndex); - } - else { - emitCommonJSModule(node, startIndex); - } + var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1 /* CommonJS */]; + emitModule(node); } else { + // emit prologue directives prior to __extends + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); externalImports = undefined; exportSpecifiers = undefined; exportEquals = undefined; @@ -34596,38 +35536,38 @@ var ts; switch (node.kind) { // All of these entities are emitted in a specialized fashion. As such, we allow // the specialized methods for each to handle the comments on the nodes. - case 213 /* InterfaceDeclaration */: - case 211 /* FunctionDeclaration */: - case 220 /* ImportDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 225 /* ExportAssignment */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 227 /* ExportAssignment */: return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well. return shouldEmitModuleDeclaration(node); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: // Only emit the leading/trailing comments for an enum if we're actually // emitting the module as well. return shouldEmitEnumDeclaration(node); } - // If the node is emitted in specialized fashion, dont emit comments as this node will handle + // If the node is emitted in specialized fashion, dont emit comments as this node will handle // emitting comments when emitting itself ts.Debug.assert(!isSpecializedCommentHandling(node)); // If this is the expression body of an arrow function that we're down-leveling, // then we don't want to emit comments when we emit the body. It will have already // been taken care of when we emitted the 'return' statement for the function // expression body. - if (node.kind !== 190 /* Block */ && + if (node.kind !== 192 /* Block */ && node.parent && - node.parent.kind === 172 /* ArrowFunction */ && + node.parent.kind === 174 /* ArrowFunction */ && node.parent.body === node && compilerOptions.target <= 1 /* ES5 */) { return false; @@ -34638,25 +35578,25 @@ var ts; function emitJavaScriptWorker(node) { // Check if the node can be emitted regardless of the ScriptTarget switch (node.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: return emitIdentifier(node); - case 136 /* Parameter */: + case 138 /* Parameter */: return emitParameter(node); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return emitMethod(node); - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return emitAccessor(node); - case 95 /* ThisKeyword */: + case 97 /* ThisKeyword */: return emitThis(node); - case 93 /* SuperKeyword */: + case 95 /* SuperKeyword */: return emitSuper(node); - case 91 /* NullKeyword */: + case 93 /* NullKeyword */: return write("null"); - case 97 /* TrueKeyword */: + case 99 /* TrueKeyword */: return write("true"); - case 82 /* FalseKeyword */: + case 84 /* FalseKeyword */: return write("false"); case 8 /* NumericLiteral */: case 9 /* StringLiteral */: @@ -34666,142 +35606,142 @@ var ts; case 13 /* TemplateMiddle */: case 14 /* TemplateTail */: return emitLiteral(node); - case 181 /* TemplateExpression */: + case 183 /* TemplateExpression */: return emitTemplateExpression(node); - case 188 /* TemplateSpan */: + case 190 /* TemplateSpan */: return emitTemplateSpan(node); - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: return emitJsxElement(node); - case 234 /* JsxText */: + case 236 /* JsxText */: return emitJsxText(node); - case 238 /* JsxExpression */: + case 240 /* JsxExpression */: return emitJsxExpression(node); - case 133 /* QualifiedName */: + case 135 /* QualifiedName */: return emitQualifiedName(node); - case 159 /* ObjectBindingPattern */: + case 161 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 160 /* ArrayBindingPattern */: + case 162 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 161 /* BindingElement */: + case 163 /* BindingElement */: return emitBindingElement(node); - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 243 /* PropertyAssignment */: + case 245 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 244 /* ShorthandPropertyAssignment */: + case 246 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: return emitComputedPropertyName(node); - case 164 /* PropertyAccessExpression */: + case 166 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 165 /* ElementAccessExpression */: + case 167 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 166 /* CallExpression */: + case 168 /* CallExpression */: return emitCallExpression(node); - case 167 /* NewExpression */: + case 169 /* NewExpression */: return emitNewExpression(node); - case 168 /* TaggedTemplateExpression */: + case 170 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 169 /* TypeAssertionExpression */: + case 171 /* TypeAssertionExpression */: return emit(node.expression); - case 187 /* AsExpression */: + case 189 /* AsExpression */: return emit(node.expression); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return emitParenExpression(node); - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 173 /* DeleteExpression */: + case 175 /* DeleteExpression */: return emitDeleteExpression(node); - case 174 /* TypeOfExpression */: + case 176 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 175 /* VoidExpression */: + case 177 /* VoidExpression */: return emitVoidExpression(node); - case 176 /* AwaitExpression */: + case 178 /* AwaitExpression */: return emitAwaitExpression(node); - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 178 /* PostfixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return emitBinaryExpression(node); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return emitConditionalExpression(node); - case 183 /* SpreadElementExpression */: + case 185 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 182 /* YieldExpression */: + case 184 /* YieldExpression */: return emitYieldExpression(node); - case 185 /* OmittedExpression */: + case 187 /* OmittedExpression */: return; - case 190 /* Block */: - case 217 /* ModuleBlock */: + case 192 /* Block */: + case 219 /* ModuleBlock */: return emitBlock(node); - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: return emitVariableStatement(node); - case 192 /* EmptyStatement */: + case 194 /* EmptyStatement */: return write(";"); - case 193 /* ExpressionStatement */: + case 195 /* ExpressionStatement */: return emitExpressionStatement(node); - case 194 /* IfStatement */: + case 196 /* IfStatement */: return emitIfStatement(node); - case 195 /* DoStatement */: + case 197 /* DoStatement */: return emitDoStatement(node); - case 196 /* WhileStatement */: + case 198 /* WhileStatement */: return emitWhileStatement(node); - case 197 /* ForStatement */: + case 199 /* ForStatement */: return emitForStatement(node); - case 199 /* ForOfStatement */: - case 198 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 200 /* ForInStatement */: return emitForInOrForOfStatement(node); - case 200 /* ContinueStatement */: - case 201 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 202 /* ReturnStatement */: + case 204 /* ReturnStatement */: return emitReturnStatement(node); - case 203 /* WithStatement */: + case 205 /* WithStatement */: return emitWithStatement(node); - case 204 /* SwitchStatement */: + case 206 /* SwitchStatement */: return emitSwitchStatement(node); - case 239 /* CaseClause */: - case 240 /* DefaultClause */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: return emitLabelledStatement(node); - case 206 /* ThrowStatement */: + case 208 /* ThrowStatement */: return emitThrowStatement(node); - case 207 /* TryStatement */: + case 209 /* TryStatement */: return emitTryStatement(node); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return emitCatchClause(node); - case 208 /* DebuggerStatement */: + case 210 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 209 /* VariableDeclaration */: + case 211 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 184 /* ClassExpression */: + case 186 /* ClassExpression */: return emitClassExpression(node); - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: return emitClassDeclaration(node); - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 245 /* EnumMember */: + case 247 /* EnumMember */: return emitEnumMember(node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: return emitImportDeclaration(node); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return emitExportDeclaration(node); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return emitExportAssignment(node); - case 246 /* SourceFile */: + case 248 /* SourceFile */: return emitSourceFileNode(node); } } @@ -34844,7 +35784,7 @@ var ts; function getLeadingCommentsToEmit(node) { // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 246 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 248 /* SourceFile */ || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { // get comments without detached comments return getLeadingCommentsWithoutDetachedComments(); @@ -34859,7 +35799,7 @@ var ts; function getTrailingCommentsToEmit(node) { // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 246 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 248 /* SourceFile */ || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -34997,6 +35937,7 @@ var ts; write(shebang); } } + var _a; } function emitFile(jsFilePath, sourceFile) { emitJavaScript(jsFilePath, sourceFile); @@ -35006,261 +35947,6 @@ var ts; } } ts.emitFiles = emitFiles; - var entities = { - "quot": 0x0022, - "amp": 0x0026, - "apos": 0x0027, - "lt": 0x003C, - "gt": 0x003E, - "nbsp": 0x00A0, - "iexcl": 0x00A1, - "cent": 0x00A2, - "pound": 0x00A3, - "curren": 0x00A4, - "yen": 0x00A5, - "brvbar": 0x00A6, - "sect": 0x00A7, - "uml": 0x00A8, - "copy": 0x00A9, - "ordf": 0x00AA, - "laquo": 0x00AB, - "not": 0x00AC, - "shy": 0x00AD, - "reg": 0x00AE, - "macr": 0x00AF, - "deg": 0x00B0, - "plusmn": 0x00B1, - "sup2": 0x00B2, - "sup3": 0x00B3, - "acute": 0x00B4, - "micro": 0x00B5, - "para": 0x00B6, - "middot": 0x00B7, - "cedil": 0x00B8, - "sup1": 0x00B9, - "ordm": 0x00BA, - "raquo": 0x00BB, - "frac14": 0x00BC, - "frac12": 0x00BD, - "frac34": 0x00BE, - "iquest": 0x00BF, - "Agrave": 0x00C0, - "Aacute": 0x00C1, - "Acirc": 0x00C2, - "Atilde": 0x00C3, - "Auml": 0x00C4, - "Aring": 0x00C5, - "AElig": 0x00C6, - "Ccedil": 0x00C7, - "Egrave": 0x00C8, - "Eacute": 0x00C9, - "Ecirc": 0x00CA, - "Euml": 0x00CB, - "Igrave": 0x00CC, - "Iacute": 0x00CD, - "Icirc": 0x00CE, - "Iuml": 0x00CF, - "ETH": 0x00D0, - "Ntilde": 0x00D1, - "Ograve": 0x00D2, - "Oacute": 0x00D3, - "Ocirc": 0x00D4, - "Otilde": 0x00D5, - "Ouml": 0x00D6, - "times": 0x00D7, - "Oslash": 0x00D8, - "Ugrave": 0x00D9, - "Uacute": 0x00DA, - "Ucirc": 0x00DB, - "Uuml": 0x00DC, - "Yacute": 0x00DD, - "THORN": 0x00DE, - "szlig": 0x00DF, - "agrave": 0x00E0, - "aacute": 0x00E1, - "acirc": 0x00E2, - "atilde": 0x00E3, - "auml": 0x00E4, - "aring": 0x00E5, - "aelig": 0x00E6, - "ccedil": 0x00E7, - "egrave": 0x00E8, - "eacute": 0x00E9, - "ecirc": 0x00EA, - "euml": 0x00EB, - "igrave": 0x00EC, - "iacute": 0x00ED, - "icirc": 0x00EE, - "iuml": 0x00EF, - "eth": 0x00F0, - "ntilde": 0x00F1, - "ograve": 0x00F2, - "oacute": 0x00F3, - "ocirc": 0x00F4, - "otilde": 0x00F5, - "ouml": 0x00F6, - "divide": 0x00F7, - "oslash": 0x00F8, - "ugrave": 0x00F9, - "uacute": 0x00FA, - "ucirc": 0x00FB, - "uuml": 0x00FC, - "yacute": 0x00FD, - "thorn": 0x00FE, - "yuml": 0x00FF, - "OElig": 0x0152, - "oelig": 0x0153, - "Scaron": 0x0160, - "scaron": 0x0161, - "Yuml": 0x0178, - "fnof": 0x0192, - "circ": 0x02C6, - "tilde": 0x02DC, - "Alpha": 0x0391, - "Beta": 0x0392, - "Gamma": 0x0393, - "Delta": 0x0394, - "Epsilon": 0x0395, - "Zeta": 0x0396, - "Eta": 0x0397, - "Theta": 0x0398, - "Iota": 0x0399, - "Kappa": 0x039A, - "Lambda": 0x039B, - "Mu": 0x039C, - "Nu": 0x039D, - "Xi": 0x039E, - "Omicron": 0x039F, - "Pi": 0x03A0, - "Rho": 0x03A1, - "Sigma": 0x03A3, - "Tau": 0x03A4, - "Upsilon": 0x03A5, - "Phi": 0x03A6, - "Chi": 0x03A7, - "Psi": 0x03A8, - "Omega": 0x03A9, - "alpha": 0x03B1, - "beta": 0x03B2, - "gamma": 0x03B3, - "delta": 0x03B4, - "epsilon": 0x03B5, - "zeta": 0x03B6, - "eta": 0x03B7, - "theta": 0x03B8, - "iota": 0x03B9, - "kappa": 0x03BA, - "lambda": 0x03BB, - "mu": 0x03BC, - "nu": 0x03BD, - "xi": 0x03BE, - "omicron": 0x03BF, - "pi": 0x03C0, - "rho": 0x03C1, - "sigmaf": 0x03C2, - "sigma": 0x03C3, - "tau": 0x03C4, - "upsilon": 0x03C5, - "phi": 0x03C6, - "chi": 0x03C7, - "psi": 0x03C8, - "omega": 0x03C9, - "thetasym": 0x03D1, - "upsih": 0x03D2, - "piv": 0x03D6, - "ensp": 0x2002, - "emsp": 0x2003, - "thinsp": 0x2009, - "zwnj": 0x200C, - "zwj": 0x200D, - "lrm": 0x200E, - "rlm": 0x200F, - "ndash": 0x2013, - "mdash": 0x2014, - "lsquo": 0x2018, - "rsquo": 0x2019, - "sbquo": 0x201A, - "ldquo": 0x201C, - "rdquo": 0x201D, - "bdquo": 0x201E, - "dagger": 0x2020, - "Dagger": 0x2021, - "bull": 0x2022, - "hellip": 0x2026, - "permil": 0x2030, - "prime": 0x2032, - "Prime": 0x2033, - "lsaquo": 0x2039, - "rsaquo": 0x203A, - "oline": 0x203E, - "frasl": 0x2044, - "euro": 0x20AC, - "image": 0x2111, - "weierp": 0x2118, - "real": 0x211C, - "trade": 0x2122, - "alefsym": 0x2135, - "larr": 0x2190, - "uarr": 0x2191, - "rarr": 0x2192, - "darr": 0x2193, - "harr": 0x2194, - "crarr": 0x21B5, - "lArr": 0x21D0, - "uArr": 0x21D1, - "rArr": 0x21D2, - "dArr": 0x21D3, - "hArr": 0x21D4, - "forall": 0x2200, - "part": 0x2202, - "exist": 0x2203, - "empty": 0x2205, - "nabla": 0x2207, - "isin": 0x2208, - "notin": 0x2209, - "ni": 0x220B, - "prod": 0x220F, - "sum": 0x2211, - "minus": 0x2212, - "lowast": 0x2217, - "radic": 0x221A, - "prop": 0x221D, - "infin": 0x221E, - "ang": 0x2220, - "and": 0x2227, - "or": 0x2228, - "cap": 0x2229, - "cup": 0x222A, - "int": 0x222B, - "there4": 0x2234, - "sim": 0x223C, - "cong": 0x2245, - "asymp": 0x2248, - "ne": 0x2260, - "equiv": 0x2261, - "le": 0x2264, - "ge": 0x2265, - "sub": 0x2282, - "sup": 0x2283, - "nsub": 0x2284, - "sube": 0x2286, - "supe": 0x2287, - "oplus": 0x2295, - "otimes": 0x2297, - "perp": 0x22A5, - "sdot": 0x22C5, - "lceil": 0x2308, - "rceil": 0x2309, - "lfloor": 0x230A, - "rfloor": 0x230B, - "lang": 0x2329, - "rang": 0x232A, - "loz": 0x25CA, - "spades": 0x2660, - "clubs": 0x2663, - "hearts": 0x2665, - "diams": 0x2666 - }; })(ts || (ts = {})); /// /// @@ -35311,11 +35997,11 @@ var ts; if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { var failedLookupLocations = []; var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + var resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (resolvedFileName) { return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; } - resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); return resolvedFileName ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; @@ -35325,13 +36011,8 @@ var ts; } } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { - if (loadOnlyDts) { - return tryLoad(".d.ts"); - } - else { - return ts.forEach(ts.supportedExtensions, tryLoad); - } + function loadNodeModuleFromFile(candidate, failedLookupLocation, host) { + return ts.forEach(ts.supportedJsExtensions, tryLoad); function tryLoad(ext) { var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; if (host.fileExists(fileName)) { @@ -35343,7 +36024,7 @@ var ts; } } } - function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + function loadNodeModuleFromDirectory(candidate, failedLookupLocation, host) { var packageJsonPath = ts.combinePaths(candidate, "package.json"); if (host.fileExists(packageJsonPath)) { var jsonContent; @@ -35356,7 +36037,7 @@ var ts; jsonContent = { typings: undefined }; } if (jsonContent.typings) { - var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); if (result) { return result; } @@ -35366,7 +36047,7 @@ var ts; // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results failedLookupLocation.push(packageJsonPath); } - return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), failedLookupLocation, host); } function loadModuleFromNodeModules(moduleName, directory, host) { var failedLookupLocations = []; @@ -35376,11 +36057,11 @@ var ts; if (baseName !== "node_modules") { var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + var result = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; } - result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; } @@ -35399,16 +36080,17 @@ var ts; } function classicNameResolver(moduleName, containingFile, compilerOptions, host) { // module names that contain '!' are used to reference resources and are not resolved to actual files on disk - if (moduleName.indexOf('!') != -1) { + if (moduleName.indexOf("!") != -1) { return { resolvedModule: undefined, failedLookupLocations: [] }; } var searchPath = ts.getDirectoryPath(containingFile); var searchName; var failedLookupLocations = []; var referencedSourceFile; + var extensions = compilerOptions.allowNonTsExtensions ? ts.supportedJsExtensions : ts.supportedExtensions; while (true) { searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + referencedSourceFile = ts.forEach(extensions, function (extension) { if (extension === ".tsx" && !compilerOptions.jsx) { // resolve .tsx files only if jsx support is enabled // 'logical not' handles both undefined and None cases @@ -35746,7 +36428,9 @@ var ts; return emitResult; } function getSourceFile(fileName) { - return filesByName.get(fileName); + // first try to use file name as is to find file + // then try to convert relative file name to absolute and use it to retrieve source file + return filesByName.get(fileName) || filesByName.get(ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory())); } function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { @@ -35842,13 +36526,18 @@ var ts; if (file.imports) { return; } + var isJavaScriptFile = ts.isSourceFileJavaScript(file); var imports; for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var node = _a[_i]; + collect(node, /* allowRelativeModuleNames */ true); + } + file.imports = imports || emptyArray; + function collect(node, allowRelativeModuleNames) { switch (node.kind) { - case 220 /* ImportDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 226 /* ExportDeclaration */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 228 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -35856,9 +36545,24 @@ var ts; if (!moduleNameExpr.text) { break; } - (imports || (imports = [])).push(moduleNameExpr); + if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { + (imports || (imports = [])).push(moduleNameExpr); + } + break; + case 168 /* CallExpression */: + if (isJavaScriptFile && ts.isRequireCall(node)) { + var jsImports = node.arguments; + if (jsImports) { + imports = (imports || []); + for (var i = 0; i < jsImports.length; i++) { + if (jsImports[i].kind === 9 /* StringLiteral */) { + imports.push(jsImports[i]); + } + } + } + } break; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 // An AmbientExternalModuleDeclaration declares an external module. @@ -35866,22 +36570,18 @@ var ts; // The StringLiteral must specify a top - level external module name. // Relative external module names are not permitted ts.forEachChild(node.body, function (node) { - if (ts.isExternalModuleImportEqualsDeclaration(node) && - ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9 /* StringLiteral */) { - var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules - // only through top - level external module names. Relative external module names are not permitted. - if (moduleName) { - (imports || (imports = [])).push(moduleName); - } - } + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules + // only through top - level external module names. Relative external module names are not permitted. + collect(node, /* allowRelativeModuleNames */ false); }); } break; } + if (ts.isSourceFileJavaScript(file)) { + ts.forEachChild(node, function (node) { return collect(node, allowRelativeModuleNames); }); + } } - file.imports = imports || emptyArray; } function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; @@ -35925,52 +36625,52 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - if (filesByName.contains(canonicalName)) { + if (filesByName.contains(fileName)) { // We've already looked for this file, use cached result - return getSourceFileFromCache(fileName, canonicalName, /*useAbsolutePath*/ false); + return getSourceFileFromCache(fileName, /*useAbsolutePath*/ false); } - else { - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); - var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); - if (filesByName.contains(canonicalAbsolutePath)) { - return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, /*useAbsolutePath*/ true); + var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); + if (filesByName.contains(normalizedAbsolutePath)) { + var file_1 = getSourceFileFromCache(normalizedAbsolutePath, /*useAbsolutePath*/ true); + // we don't have resolution for this relative file name but the match was found by absolute file name + // store resolution for relative name as well + filesByName.set(fileName, file_1); + return file_1; + } + // We haven't looked for this file, do so now and cache result + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } - // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }); - filesByName.set(canonicalName, file); - if (file) { - skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - // Set the source file for normalized absolute path - filesByName.set(canonicalAbsolutePath, file); - var basePath = ts.getDirectoryPath(fileName); - if (!options.noResolve) { - processReferencedFiles(file, basePath); - } - // always process imported modules to record module name resolutions - processImportedModules(file, basePath); - if (isDefaultLib) { - file.isDefaultLib = true; - files.unshift(file); - } - else { - files.push(file); - } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + }); + filesByName.set(fileName, file); + if (file) { + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + // Set the source file for normalized absolute path + filesByName.set(normalizedAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); + if (!options.noResolve) { + processReferencedFiles(file, basePath); + } + // always process imported modules to record module name resolutions + processImportedModules(file, basePath); + if (isDefaultLib) { + file.isDefaultLib = true; + files.unshift(file); + } + else { + files.push(file); } - return file; } - function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) { - var file = filesByName.get(canonicalName); + return file; + function getSourceFileFromCache(fileName, useAbsolutePath) { + var file = filesByName.get(fileName); if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; - if (canonicalName !== sourceFileName) { + if (ts.normalizeSlashes(fileName) !== ts.normalizeSlashes(sourceFileName)) { if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); } @@ -36138,9 +36838,9 @@ var ts; var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } - // Cannot specify module gen target when in es6 or above - if (options.module && languageVersion >= 2 /* ES6 */) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); + // Cannot specify module gen target of es6 when below es6 + if (options.module === 5 /* ES6 */ && languageVersion < 2 /* ES6 */) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower)); } // there has to be common source directory if user specified --outdir || --sourceRoot // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted @@ -36181,10 +36881,6 @@ var ts; !options.experimentalDecorators) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } - if (options.experimentalAsyncFunctions && - options.target !== 2 /* ES6 */) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); - } } } ts.createProgram = createProgram; @@ -36266,11 +36962,12 @@ var ts; "commonjs": 1 /* CommonJS */, "amd": 2 /* AMD */, "system": 4 /* System */, - "umd": 3 /* UMD */ + "umd": 3 /* UMD */, + "es6": 5 /* ES6 */ }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_or_umd, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6 }, { name: "newLine", @@ -36412,11 +37109,6 @@ var ts; type: "boolean", description: ts.Diagnostics.Watch_input_files }, - { - name: "experimentalAsyncFunctions", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_async_functions - }, { name: "experimentalDecorators", type: "boolean", @@ -36622,6 +37314,9 @@ var ts; } if (opt.isFilePath) { value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } } options[opt.name] = value; } @@ -36650,20 +37345,20 @@ var ts; var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); for (var i = 0; i < sysFiles.length; i++) { - var name_27 = sysFiles[i]; - if (ts.fileExtensionIs(name_27, ".d.ts")) { - var baseName = name_27.substr(0, name_27.length - ".d.ts".length); + var name_28 = sysFiles[i]; + if (ts.fileExtensionIs(name_28, ".d.ts")) { + var baseName = name_28.substr(0, name_28.length - ".d.ts".length); if (!ts.contains(sysFiles, baseName + ".tsx") && !ts.contains(sysFiles, baseName + ".ts")) { - fileNames.push(name_27); + fileNames.push(name_28); } } - else if (ts.fileExtensionIs(name_27, ".ts")) { - if (!ts.contains(sysFiles, name_27 + "x")) { - fileNames.push(name_27); + else if (ts.fileExtensionIs(name_28, ".ts")) { + if (!ts.contains(sysFiles, name_28 + "x")) { + fileNames.push(name_28); } } else { - fileNames.push(name_27); + fileNames.push(name_28); } } } @@ -36744,7 +37439,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 172 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 174 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -36756,7 +37451,7 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 190 /* Block */: + case 192 /* Block */: if (!ts.isFunctionBlock(n)) { var parent_7 = n.parent; var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); @@ -36764,18 +37459,18 @@ var ts; // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collaps the block, but consider its hint span // to be the entire span of the parent. - if (parent_7.kind === 195 /* DoStatement */ || - parent_7.kind === 198 /* ForInStatement */ || - parent_7.kind === 199 /* ForOfStatement */ || - parent_7.kind === 197 /* ForStatement */ || - parent_7.kind === 194 /* IfStatement */ || - parent_7.kind === 196 /* WhileStatement */ || - parent_7.kind === 203 /* WithStatement */ || - parent_7.kind === 242 /* CatchClause */) { + if (parent_7.kind === 197 /* DoStatement */ || + parent_7.kind === 200 /* ForInStatement */ || + parent_7.kind === 201 /* ForOfStatement */ || + parent_7.kind === 199 /* ForStatement */ || + parent_7.kind === 196 /* IfStatement */ || + parent_7.kind === 198 /* WhileStatement */ || + parent_7.kind === 205 /* WithStatement */ || + parent_7.kind === 244 /* CatchClause */) { addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_7.kind === 207 /* TryStatement */) { + if (parent_7.kind === 209 /* TryStatement */) { // Could be the try-block, or the finally-block. var tryStatement = parent_7; if (tryStatement.tryBlock === n) { @@ -36783,7 +37478,7 @@ var ts; break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -36802,23 +37497,23 @@ var ts; break; } // Fallthrough. - case 217 /* ModuleBlock */: { + case 219 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 163 /* ObjectLiteralExpression */: - case 218 /* CaseBlock */: { + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 165 /* ObjectLiteralExpression */: + case 220 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -36846,12 +37541,12 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_28 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_28); + for (var name_29 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_29); if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_28); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_29); if (!matches) { continue; } @@ -36864,14 +37559,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_28); + matches = patternMatcher.getMatches(containers, name_29); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_28, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_29, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -36895,7 +37590,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 67 /* Identifier */ || + if (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { return node.text; @@ -36909,7 +37604,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 134 /* ComputedPropertyName */) { + else if (declaration.name.kind === 136 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ true); } else { @@ -36930,7 +37625,7 @@ var ts; } return true; } - if (expression.kind === 164 /* PropertyAccessExpression */) { + if (expression.kind === 166 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -36943,7 +37638,7 @@ var ts; var containers = []; // First, if we started with a computed property name, then add all but the last // portion into the container array. - if (declaration.name.kind === 134 /* ComputedPropertyName */) { + if (declaration.name.kind === 136 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ false)) { return undefined; } @@ -37019,17 +37714,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: // If we have a module declared as A.B.C, it is more "intuitive" // to say it only has a single layer of depth do { current = current.parent; - } while (current.kind === 216 /* ModuleDeclaration */); + } while (current.kind === 218 /* ModuleDeclaration */); // fall through - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: - case 213 /* InterfaceDeclaration */: - case 211 /* FunctionDeclaration */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -37040,21 +37735,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 159 /* ObjectBindingPattern */: - case 160 /* ArrayBindingPattern */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -37066,7 +37761,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -37075,21 +37770,21 @@ var ts; } } break; - case 161 /* BindingElement */: - case 209 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 211 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: - case 213 /* InterfaceDeclaration */: - case 216 /* ModuleDeclaration */: - case 211 /* FunctionDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 224 /* ImportSpecifier */: - case 228 /* ExportSpecifier */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: + case 218 /* ModuleDeclaration */: + case 213 /* FunctionDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: childNodes.push(node); break; } @@ -37137,17 +37832,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: - case 213 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -37158,12 +37853,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 211 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 213 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 190 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 192 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 211 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 213 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -37223,7 +37918,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 136 /* Parameter */: + case 138 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } @@ -37231,36 +37926,36 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 143 /* GetAccessor */: + case 145 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 144 /* SetAccessor */: + case 146 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 147 /* IndexSignature */: + case 149 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 245 /* EnumMember */: + case 247 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 145 /* CallSignature */: + case 147 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 146 /* ConstructSignature */: + case 148 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: var variableDeclarationNode; - var name_29; - if (node.kind === 161 /* BindingElement */) { - name_29 = node.name; + var name_30; + if (node.kind === 163 /* BindingElement */) { + name_30 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 209 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 211 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -37268,24 +37963,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_29 = node.name; + name_30 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.variableElement); } - case 142 /* Constructor */: + case 144 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 228 /* ExportSpecifier */: - case 224 /* ImportSpecifier */: - case 219 /* ImportEqualsDeclaration */: - case 221 /* ImportClause */: - case 222 /* NamespaceImport */: + case 230 /* ExportSpecifier */: + case 226 /* ImportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -37315,17 +38010,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 246 /* SourceFile */: + case 248 /* SourceFile */: return createSourceFileItem(node); - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: return createClassItem(node); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return createEnumItem(node); - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return createModuleItem(node); - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; @@ -37337,7 +38032,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 218 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -37349,7 +38044,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.body && node.body.kind === 190 /* Block */) { + if (node.body && node.body.kind === 192 /* Block */) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -37370,7 +38065,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 142 /* Constructor */ && member; + return member.kind === 144 /* Constructor */ && member; }); // Add the constructor parameters in as children of the class (for property parameters). // Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that @@ -37394,7 +38089,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 134 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 136 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -37403,13 +38098,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 216 /* ModuleDeclaration */) { + while (node.body.kind === 218 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 246 /* SourceFile */ + return node.kind === 248 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -38197,22 +38892,22 @@ var ts; if (!candidates.length) { // We didn't have any sig help items produced by the TS compiler. If this is a JS // file, then see if we can figure out anything better. - if (ts.isJavaScript(sourceFile.fileName)) { + if (ts.isSourceFileJavaScript(sourceFile)) { return createJavaScriptSignatureHelpItems(argumentInfo); } return undefined; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 166 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 168 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 67 /* Identifier */ + var name = expression.kind === 69 /* Identifier */ ? expression - : expression.kind === 164 /* PropertyAccessExpression */ + : expression.kind === 166 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -38245,7 +38940,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 166 /* CallExpression */ || node.parent.kind === 167 /* NewExpression */) { + if (node.parent.kind === 168 /* CallExpression */ || node.parent.kind === 169 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -38298,25 +38993,25 @@ var ts; }; } } - else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 168 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 170 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0); } } - else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 168 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 170 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 183 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 188 /* TemplateSpan */ && node.parent.parent.parent.kind === 168 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 190 /* TemplateSpan */ && node.parent.parent.parent.kind === 170 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 183 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -38434,7 +39129,7 @@ var ts; // // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 181 /* TemplateExpression */) { + if (template.kind === 183 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -38443,7 +39138,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 246 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 248 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -38643,40 +39338,40 @@ var ts; return false; } switch (n.kind) { - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 163 /* ObjectLiteralExpression */: - case 159 /* ObjectBindingPattern */: - case 153 /* TypeLiteral */: - case 190 /* Block */: - case 217 /* ModuleBlock */: - case 218 /* CaseBlock */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 165 /* ObjectLiteralExpression */: + case 161 /* ObjectBindingPattern */: + case 155 /* TypeLiteral */: + case 192 /* Block */: + case 219 /* ModuleBlock */: + case 220 /* CaseBlock */: return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 167 /* NewExpression */: + case 169 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 166 /* CallExpression */: - case 170 /* ParenthesizedExpression */: - case 158 /* ParenthesizedType */: + case 168 /* CallExpression */: + case 172 /* ParenthesizedExpression */: + case 160 /* ParenthesizedType */: return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 146 /* ConstructSignature */: - case 145 /* CallSignature */: - case 172 /* ArrowFunction */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 148 /* ConstructSignature */: + case 147 /* CallSignature */: + case 174 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -38686,63 +39381,64 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 18 /* CloseParenToken */, sourceFile); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 194 /* IfStatement */: + case 196 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 193 /* ExpressionStatement */: - return isCompletedNode(n.expression, sourceFile); - case 162 /* ArrayLiteralExpression */: - case 160 /* ArrayBindingPattern */: - case 165 /* ElementAccessExpression */: - case 134 /* ComputedPropertyName */: - case 155 /* TupleType */: + case 195 /* ExpressionStatement */: + return isCompletedNode(n.expression, sourceFile) || + hasChildOfKind(n, 23 /* SemicolonToken */); + case 164 /* ArrayLiteralExpression */: + case 162 /* ArrayBindingPattern */: + case 167 /* ElementAccessExpression */: + case 136 /* ComputedPropertyName */: + case 157 /* TupleType */: return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); - case 147 /* IndexSignature */: + case 149 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); - case 239 /* CaseClause */: - case 240 /* DefaultClause */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 196 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 198 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 195 /* DoStatement */: + case 197 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - var hasWhileKeyword = findChildOfKind(n, 102 /* WhileKeyword */, sourceFile); + var hasWhileKeyword = findChildOfKind(n, 104 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 174 /* TypeOfExpression */: - case 173 /* DeleteExpression */: - case 175 /* VoidExpression */: - case 182 /* YieldExpression */: - case 183 /* SpreadElementExpression */: + case 176 /* TypeOfExpression */: + case 175 /* DeleteExpression */: + case 177 /* VoidExpression */: + case 184 /* YieldExpression */: + case 185 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 168 /* TaggedTemplateExpression */: + case 170 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 181 /* TemplateExpression */: + case 183 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 188 /* TemplateSpan */: + case 190 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -38798,7 +39494,7 @@ var ts; // for the position of the relevant node (or comma). var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { // find syntax list that covers the span of the node - if (c.kind === 269 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 271 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -38904,7 +39600,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n) || n.kind === 234 /* JsxText */) { + if (isToken(n) || n.kind === 236 /* JsxText */) { return n; } var children = n.getChildren(); @@ -38912,7 +39608,7 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n) || n.kind === 234 /* JsxText */) { + if (isToken(n) || n.kind === 236 /* JsxText */) { return n; } var children = n.getChildren(); @@ -38926,10 +39622,10 @@ var ts; // if no - position is in the node itself so we should recurse in it. // NOTE: JsxText is a weird kind of node that can contain only whitespaces (since they are not counted as trivia). // if this is the case - then we should assume that token in question is located in previous child. - if (position < child.end && (nodeHasTokens(child) || child.kind === 234 /* JsxText */)) { + if (position < child.end && (nodeHasTokens(child) || child.kind === 236 /* JsxText */)) { var start = child.getStart(sourceFile); var lookInPreviousChild = (start >= position) || - (child.kind === 234 /* JsxText */ && start === child.end); // whitespace only JsxText + (child.kind === 236 /* JsxText */ && start === child.end); // whitespace only JsxText if (lookInPreviousChild) { // actual start of the node is past the position - previous token should be at the end of previous child var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); @@ -38941,7 +39637,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 246 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 248 /* SourceFile */); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -39016,9 +39712,9 @@ var ts; var node = ts.getTokenAtPosition(sourceFile, position); if (isToken(node)) { switch (node.kind) { - case 100 /* VarKeyword */: - case 106 /* LetKeyword */: - case 72 /* ConstKeyword */: + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: // if the current token is var, let or const, skip the VariableDeclarationList node = node.parent === undefined ? undefined : node.parent.parent; break; @@ -39067,21 +39763,21 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 149 /* TypeReference */ || node.kind === 166 /* CallExpression */) { + if (node.kind === 151 /* TypeReference */ || node.kind === 168 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 212 /* ClassDeclaration */ || node.kind === 213 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 214 /* ClassDeclaration */ || node.kind === 215 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 132 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 134 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { - return kind === 67 /* Identifier */ || ts.isKeyword(kind); + return kind === 69 /* Identifier */ || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { @@ -39091,8 +39787,17 @@ var ts; return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; } ts.isComment = isComment; + function isStringOrRegularExpressionOrTemplateLiteral(kind) { + if (kind === 9 /* StringLiteral */ + || kind === 10 /* RegularExpressionLiteral */ + || ts.isTemplateLiteralKind(kind)) { + return true; + } + return false; + } + ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 15 /* FirstPunctuation */ <= kind && kind <= 66 /* LastPunctuation */; + return 15 /* FirstPunctuation */ <= kind && kind <= 68 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -39102,9 +39807,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: return true; } return false; @@ -39132,7 +39837,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 136 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 138 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -39154,7 +39859,8 @@ var ts; increaseIndent: function () { indent++; }, decreaseIndent: function () { indent--; }, clear: resetWriter, - trackSymbol: function () { } + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } }; function writeIndent() { if (lineStart) { @@ -39319,7 +40025,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 224 /* ImportSpecifier */ || location.parent.kind === 228 /* ExportSpecifier */) && + (location.parent.kind === 226 /* ImportSpecifier */ || location.parent.kind === 230 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -39347,7 +40053,12 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false); + var standardScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + var jsxScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); + /** + * Scanner that is currently used for formatting + */ + var scanner; var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; @@ -39357,6 +40068,8 @@ var ts; ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; })(ScanAction || (ScanAction = {})); function getFormattingScanner(sourceFile, startPos, endPos) { + ts.Debug.assert(scanner === undefined); + scanner = sourceFile.languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; scanner.setText(sourceFile.text); scanner.setTextPos(startPos); var wasNewLine = true; @@ -39371,11 +40084,14 @@ var ts; isOnToken: isOnToken, lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, close: function () { + ts.Debug.assert(scanner !== undefined); lastTokenInfo = undefined; scanner.setText(undefined); + scanner = undefined; } }; function advance() { + ts.Debug.assert(scanner !== undefined); lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { @@ -39419,10 +40135,10 @@ var ts; if (node) { switch (node.kind) { case 29 /* GreaterThanEqualsToken */: - case 62 /* GreaterThanGreaterThanEqualsToken */: - case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 44 /* GreaterThanGreaterThanGreaterThanToken */: - case 43 /* GreaterThanGreaterThanToken */: + case 64 /* GreaterThanGreaterThanEqualsToken */: + case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 45 /* GreaterThanGreaterThanGreaterThanToken */: + case 44 /* GreaterThanGreaterThanToken */: return true; } } @@ -39431,11 +40147,11 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 236 /* JsxAttribute */: - case 233 /* JsxOpeningElement */: - case 235 /* JsxClosingElement */: - case 232 /* JsxSelfClosingElement */: - return node.kind === 67 /* Identifier */; + case 238 /* JsxAttribute */: + case 235 /* JsxOpeningElement */: + case 237 /* JsxClosingElement */: + case 234 /* JsxSelfClosingElement */: + return node.kind === 69 /* Identifier */; } } return false; @@ -39448,9 +40164,10 @@ var ts; container.kind === 14 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 38 /* SlashToken */ || t === 59 /* SlashEqualsToken */; + return t === 39 /* SlashToken */ || t === 61 /* SlashEqualsToken */; } function readTokenInfo(n) { + ts.Debug.assert(scanner !== undefined); if (!isOnToken()) { // scanner is not on the token (either advance was not called yet or scanner is already past the end position) return { @@ -39500,7 +40217,7 @@ var ts; currentToken = scanner.reScanTemplateToken(); lastScanAction = 3 /* RescanTemplateToken */; } - else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 67 /* Identifier */) { + else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 69 /* Identifier */) { currentToken = scanner.scanJsxIdentifier(); lastScanAction = 4 /* RescanJsxIdentifier */; } @@ -39544,6 +40261,7 @@ var ts; return fixTokenKind(lastTokenInfo, n); } function isOnToken() { + ts.Debug.assert(scanner !== undefined); var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); @@ -39822,17 +40540,17 @@ var ts; this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2 /* SingleLineCommentTrivia */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1 /* Ignore */)); // Space after keyword but not before ; or : or ? this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Space after }. this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 78 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 102 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 80 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 104 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 20 /* CloseBracketToken */, 24 /* CommaToken */, 23 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // No space for dot this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); @@ -39844,10 +40562,10 @@ var ts; this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 3 /* MultiLineCommentTrivia */, 71 /* ClassKeyword */]); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 3 /* MultiLineCommentTrivia */, 73 /* ClassKeyword */]); this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a control flow construct - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 77 /* DoKeyword */, 98 /* TryKeyword */, 83 /* FinallyKeyword */, 78 /* ElseKeyword */]); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 79 /* DoKeyword */, 100 /* TryKeyword */, 85 /* FinallyKeyword */, 80 /* ElseKeyword */]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); @@ -39861,55 +40579,55 @@ var ts; // Prefix operators generally shouldn't have a space between // them and their target unary expression. this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100 /* VarKeyword */, 96 /* ThrowKeyword */, 90 /* NewKeyword */, 76 /* DeleteKeyword */, 92 /* ReturnKeyword */, 99 /* TypeOfKeyword */, 117 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106 /* LetKeyword */, 72 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([102 /* VarKeyword */, 98 /* ThrowKeyword */, 92 /* NewKeyword */, 78 /* DeleteKeyword */, 94 /* ReturnKeyword */, 101 /* TypeOfKeyword */, 119 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([108 /* LetKeyword */, 74 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(87 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(101 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(92 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 77 /* DoKeyword */, 78 /* ElseKeyword */, 69 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 79 /* DoKeyword */, 80 /* ElseKeyword */, 71 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([98 /* TryKeyword */, 83 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([100 /* TryKeyword */, 85 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([121 /* GetKeyword */, 127 /* SetKeyword */]), 67 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* GetKeyword */, 129 /* SetKeyword */]), 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. 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 /* Space */)); 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 /* Space */)); // TypeScript-specific higher priority rules // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(119 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* ModuleKeyword */, 125 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125 /* ModuleKeyword */, 127 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 71 /* ClassKeyword */, 120 /* DeclareKeyword */, 75 /* DefaultKeyword */, 79 /* EnumKeyword */, 80 /* ExportKeyword */, 81 /* ExtendsKeyword */, 121 /* GetKeyword */, 104 /* ImplementsKeyword */, 87 /* ImportKeyword */, 105 /* InterfaceKeyword */, 123 /* ModuleKeyword */, 124 /* NamespaceKeyword */, 108 /* PrivateKeyword */, 110 /* PublicKeyword */, 109 /* ProtectedKeyword */, 127 /* SetKeyword */, 111 /* StaticKeyword */, 130 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([81 /* ExtendsKeyword */, 104 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 73 /* ClassKeyword */, 122 /* DeclareKeyword */, 77 /* DefaultKeyword */, 81 /* EnumKeyword */, 82 /* ExportKeyword */, 83 /* ExtendsKeyword */, 123 /* GetKeyword */, 106 /* ImplementsKeyword */, 89 /* ImportKeyword */, 107 /* InterfaceKeyword */, 125 /* ModuleKeyword */, 126 /* NamespaceKeyword */, 110 /* PrivateKeyword */, 112 /* PublicKeyword */, 111 /* ProtectedKeyword */, 129 /* SetKeyword */, 113 /* StaticKeyword */, 132 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83 /* ExtendsKeyword */, 106 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Optional parameters and let args - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 67 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); // generics and type assertions this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseParenToken */, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); @@ -39920,17 +40638,20 @@ var ts; // Remove spaces in empty interface literals. e.g.: x: {} this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); // decorators - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 67 /* Identifier */, 80 /* ExportKeyword */, 75 /* DefaultKeyword */, 71 /* ClassKeyword */, 111 /* StaticKeyword */, 110 /* PublicKeyword */, 108 /* PrivateKeyword */, 109 /* ProtectedKeyword */, 121 /* GetKeyword */, 127 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 69 /* Identifier */, 82 /* ExportKeyword */, 77 /* DefaultKeyword */, 73 /* ClassKeyword */, 113 /* StaticKeyword */, 112 /* PublicKeyword */, 110 /* PrivateKeyword */, 111 /* ProtectedKeyword */, 123 /* GetKeyword */, 129 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); // Async-await - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 87 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // template string - this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12 /* TemplateHead */, 13 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13 /* TemplateMiddle */, 14 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ @@ -39957,8 +40678,8 @@ var ts; this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, - this.SpaceBetweenAsyncAndFunctionKeyword, - this.SpaceBetweenTagAndTemplateString, + this.SpaceBetweenAsyncAndOpenParen, this.SpaceBetweenAsyncAndFunctionKeyword, + this.SpaceBetweenTagAndTemplateString, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail, // TypeScript-specific rules this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, @@ -40026,14 +40747,14 @@ var ts; this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Insert space after function keyword for anonymous functions - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_30 in o) { - if (o[name_30] === rule) { - return name_30; + for (var name_31 in o) { + if (o[name_31] === rule) { + return name_31; } } throw new Error("Unknown rule"); @@ -40042,40 +40763,40 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 197 /* ForStatement */; + return context.contextNode.kind === 199 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 179 /* BinaryExpression */: - case 180 /* ConditionalExpression */: - case 187 /* AsExpression */: - case 148 /* TypePredicate */: - case 156 /* UnionType */: - case 157 /* IntersectionType */: + case 181 /* BinaryExpression */: + case 182 /* ConditionalExpression */: + case 189 /* AsExpression */: + case 150 /* TypePredicate */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 161 /* BindingElement */: + case 163 /* BindingElement */: // equals in type X = ... - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 209 /* VariableDeclaration */: + case 211 /* VariableDeclaration */: // equal in p = 0; - case 136 /* Parameter */: - case 245 /* EnumMember */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - return context.currentTokenSpan.kind === 55 /* EqualsToken */ || context.nextTokenSpan.kind === 55 /* EqualsToken */; + case 138 /* Parameter */: + case 247 /* EnumMember */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return context.currentTokenSpan.kind === 56 /* EqualsToken */ || context.nextTokenSpan.kind === 56 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 198 /* ForInStatement */: - return context.currentTokenSpan.kind === 88 /* InKeyword */ || context.nextTokenSpan.kind === 88 /* InKeyword */; + case 200 /* ForInStatement */: + return context.currentTokenSpan.kind === 90 /* InKeyword */ || context.nextTokenSpan.kind === 90 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 199 /* ForOfStatement */: - return context.currentTokenSpan.kind === 132 /* OfKeyword */ || context.nextTokenSpan.kind === 132 /* OfKeyword */; + case 201 /* ForOfStatement */: + return context.currentTokenSpan.kind === 134 /* OfKeyword */ || context.nextTokenSpan.kind === 134 /* OfKeyword */; } return false; }; @@ -40083,7 +40804,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 180 /* ConditionalExpression */; + return context.contextNode.kind === 182 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -40127,93 +40848,93 @@ var ts; return true; } switch (node.kind) { - case 190 /* Block */: - case 218 /* CaseBlock */: - case 163 /* ObjectLiteralExpression */: - case 217 /* ModuleBlock */: + case 192 /* Block */: + case 220 /* CaseBlock */: + case 165 /* ObjectLiteralExpression */: + case 219 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 145 /* CallSignature */: - case 171 /* FunctionExpression */: - case 142 /* Constructor */: - case 172 /* ArrowFunction */: + case 147 /* CallSignature */: + case 173 /* FunctionExpression */: + case 144 /* Constructor */: + case 174 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 211 /* FunctionDeclaration */ || context.contextNode.kind === 171 /* FunctionExpression */; + return context.contextNode.kind === 213 /* FunctionDeclaration */ || context.contextNode.kind === 173 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 153 /* TypeLiteral */: - case 216 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 155 /* TypeLiteral */: + case 218 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 212 /* ClassDeclaration */: - case 216 /* ModuleDeclaration */: - case 215 /* EnumDeclaration */: - case 190 /* Block */: - case 242 /* CatchClause */: - case 217 /* ModuleBlock */: - case 204 /* SwitchStatement */: + case 214 /* ClassDeclaration */: + case 218 /* ModuleDeclaration */: + case 217 /* EnumDeclaration */: + case 192 /* Block */: + case 244 /* CatchClause */: + case 219 /* ModuleBlock */: + case 206 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 194 /* IfStatement */: - case 204 /* SwitchStatement */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 196 /* WhileStatement */: - case 207 /* TryStatement */: - case 195 /* DoStatement */: - case 203 /* WithStatement */: + case 196 /* IfStatement */: + case 206 /* SwitchStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 198 /* WhileStatement */: + case 209 /* TryStatement */: + case 197 /* DoStatement */: + case 205 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 242 /* CatchClause */: + case 244 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 163 /* ObjectLiteralExpression */; + return context.contextNode.kind === 165 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 166 /* CallExpression */; + return context.contextNode.kind === 168 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 167 /* NewExpression */; + return context.contextNode.kind === 169 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -40221,6 +40942,9 @@ var ts; Rules.IsPreviousTokenNotComma = function (context) { return context.currentTokenSpan.kind !== 24 /* CommaToken */; }; + Rules.IsArrowFunctionContext = function (context) { + return context.contextNode.kind === 174 /* ArrowFunction */; + }; Rules.IsSameLineTokenContext = function (context) { return context.TokensAreOnSameLine(); }; @@ -40237,41 +40961,41 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 137 /* Decorator */; + return node.kind === 139 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 210 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 212 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 216 /* ModuleDeclaration */; + return context.contextNode.kind === 218 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 153 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 155 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 149 /* TypeReference */: - case 169 /* TypeAssertionExpression */: - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 213 /* InterfaceDeclaration */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 186 /* ExpressionWithTypeArguments */: + case 151 /* TypeReference */: + case 171 /* TypeAssertionExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 188 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -40282,13 +41006,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 169 /* TypeAssertionExpression */; + return context.contextNode.kind === 171 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 101 /* VoidKeyword */ && context.currentTokenParent.kind === 175 /* VoidExpression */; + return context.currentTokenSpan.kind === 103 /* VoidKeyword */ && context.currentTokenParent.kind === 177 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 182 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 184 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -40312,7 +41036,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 132 /* LastToken */ + 1; + this.mapRowLength = 134 /* LastToken */ + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); //new Array(this.mapRowLength * this.mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(this.map.length); //new Array(this.map.length); @@ -40507,7 +41231,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 132 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 134 /* LastToken */; token++) { result.push(token); } return result; @@ -40549,17 +41273,17 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(68 /* FirstKeyword */, 132 /* LastKeyword */); - TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 66 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([88 /* InKeyword */, 89 /* InstanceOfKeyword */, 132 /* OfKeyword */, 114 /* AsKeyword */, 122 /* IsKeyword */]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([40 /* PlusPlusToken */, 41 /* MinusMinusToken */, 49 /* TildeToken */, 48 /* ExclamationToken */]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 67 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]); + TokenRange.Keywords = TokenRange.FromRange(70 /* FirstKeyword */, 134 /* LastKeyword */); + TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 68 /* LastBinaryOperator */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90 /* InKeyword */, 91 /* InstanceOfKeyword */, 134 /* OfKeyword */, 116 /* AsKeyword */, 124 /* IsKeyword */]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41 /* PlusPlusToken */, 42 /* MinusMinusToken */, 50 /* TildeToken */, 49 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 69 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([67 /* Identifier */, 126 /* NumberKeyword */, 128 /* StringKeyword */, 118 /* BooleanKeyword */, 129 /* SymbolKeyword */, 101 /* VoidKeyword */, 115 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([69 /* Identifier */, 128 /* NumberKeyword */, 130 /* StringKeyword */, 120 /* BooleanKeyword */, 131 /* SymbolKeyword */, 103 /* VoidKeyword */, 117 /* AnyKeyword */]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -40773,17 +41497,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 190 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 246 /* SourceFile */: - case 190 /* Block */: - case 217 /* ModuleBlock */: + return body && body.kind === 192 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 248 /* SourceFile */: + case 192 /* Block */: + case 219 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -40956,9 +41680,9 @@ var ts; // - source file // - switch\default clauses if (isSomeBlock(parent.kind) || - parent.kind === 246 /* SourceFile */ || - parent.kind === 239 /* CaseClause */ || - parent.kind === 240 /* DefaultClause */) { + parent.kind === 248 /* SourceFile */ || + parent.kind === 241 /* CaseClause */ || + parent.kind === 242 /* DefaultClause */) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -40994,19 +41718,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 212 /* ClassDeclaration */: return 71 /* ClassKeyword */; - case 213 /* InterfaceDeclaration */: return 105 /* InterfaceKeyword */; - case 211 /* FunctionDeclaration */: return 85 /* FunctionKeyword */; - case 215 /* EnumDeclaration */: return 215 /* EnumDeclaration */; - case 143 /* GetAccessor */: return 121 /* GetKeyword */; - case 144 /* SetAccessor */: return 127 /* SetKeyword */; - case 141 /* MethodDeclaration */: + case 214 /* ClassDeclaration */: return 73 /* ClassKeyword */; + case 215 /* InterfaceDeclaration */: return 107 /* InterfaceKeyword */; + case 213 /* FunctionDeclaration */: return 87 /* FunctionKeyword */; + case 217 /* EnumDeclaration */: return 217 /* EnumDeclaration */; + case 145 /* GetAccessor */: return 123 /* GetKeyword */; + case 146 /* SetAccessor */: return 129 /* SetKeyword */; + case 143 /* MethodDeclaration */: if (node.asteriskToken) { return 37 /* AsteriskToken */; } // fall-through - case 139 /* PropertyDeclaration */: - case 136 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 138 /* Parameter */: return node.name.kind; } } @@ -41040,9 +41764,9 @@ var ts; case 20 /* CloseBracketToken */: case 17 /* OpenParenToken */: case 18 /* CloseParenToken */: - case 78 /* ElseKeyword */: - case 102 /* WhileKeyword */: - case 54 /* AtToken */: + case 80 /* ElseKeyword */: + case 104 /* WhileKeyword */: + case 55 /* AtToken */: return indentation; default: // if token line equals to the line of containing node (this is a first token in the node) - use node indentation @@ -41142,7 +41866,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 137 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 139 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -41399,8 +42123,8 @@ var ts; for (var line = line1; line < line2; ++line) { var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile); var lineEndPosition = ts.getEndLinePosition(line, sourceFile); - // do not trim whitespaces in comments - if (range && ts.isComment(range.kind) && range.pos <= lineEndPosition && range.end > lineEndPosition) { + // do not trim whitespaces in comments or template expression + if (range && (ts.isComment(range.kind) || ts.isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) { continue; } var pos = lineEndPosition; @@ -41466,20 +42190,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 190 /* Block */: - case 217 /* ModuleBlock */: + case 192 /* Block */: + case 219 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 142 /* Constructor */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 172 /* ArrowFunction */: + case 144 /* Constructor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 174 /* ArrowFunction */: if (node.typeParameters === list) { return 25 /* LessThanToken */; } @@ -41487,8 +42211,8 @@ var ts; return 17 /* OpenParenToken */; } break; - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: if (node.typeArguments === list) { return 25 /* LessThanToken */; } @@ -41496,7 +42220,7 @@ var ts; return 17 /* OpenParenToken */; } break; - case 149 /* TypeReference */: + case 151 /* TypeReference */: if (node.typeArguments === list) { return 25 /* LessThanToken */; } @@ -41580,22 +42304,39 @@ var ts; if (position > sourceFile.text.length) { return 0; // past EOF } + // no indentation when the indent style is set to none, + // so we can return fast + if (options.IndentStyle === ts.IndentStyle.None) { + return 0; + } var precedingToken = ts.findPrecedingToken(position, sourceFile); if (!precedingToken) { return 0; } // no indentation in string \regex\template literals - var precedingTokenIsLiteral = precedingToken.kind === 9 /* StringLiteral */ || - precedingToken.kind === 10 /* RegularExpressionLiteral */ || - precedingToken.kind === 11 /* NoSubstitutionTemplateLiteral */ || - precedingToken.kind === 12 /* TemplateHead */ || - precedingToken.kind === 13 /* TemplateMiddle */ || - precedingToken.kind === 14 /* TemplateTail */; + var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 179 /* BinaryExpression */) { + // indentation is first non-whitespace character in a previous line + // for block indentation, we should look for a line which contains something that's not + // whitespace. + if (options.IndentStyle === ts.IndentStyle.Block) { + // move backwards until we find a line with a non-whitespace character, + // then find the first non-whitespace character for that line. + var current_1 = position; + while (current_1 > 0) { + var char = sourceFile.text.charCodeAt(current_1); + if (!ts.isWhiteSpace(char) && !ts.isLineBreak(char)) { + break; + } + current_1--; + } + var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); + return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); + } + if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 181 /* BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { @@ -41714,7 +42455,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 246 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 248 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -41747,8 +42488,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 194 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 78 /* ElseKeyword */, sourceFile); + if (parent.kind === 196 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 80 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -41759,23 +42500,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 149 /* TypeReference */: + case 151 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return node.parent.properties; - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return node.parent.elements; - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: { + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -41786,8 +42527,8 @@ var ts; } break; } - case 167 /* NewExpression */: - case 166 /* CallExpression */: { + case 169 /* NewExpression */: + case 168 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -41817,8 +42558,8 @@ var ts; if (node.kind === 18 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 166 /* CallExpression */ || - node.parent.kind === 167 /* NewExpression */) && + if (node.parent && (node.parent.kind === 168 /* CallExpression */ || + node.parent.kind === 169 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -41836,10 +42577,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: node = node.expression; break; default: @@ -41904,42 +42645,43 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 162 /* ArrayLiteralExpression */: - case 190 /* Block */: - case 217 /* ModuleBlock */: - case 163 /* ObjectLiteralExpression */: - case 153 /* TypeLiteral */: - case 155 /* TupleType */: - case 218 /* CaseBlock */: - case 240 /* DefaultClause */: - case 239 /* CaseClause */: - case 170 /* ParenthesizedExpression */: - case 164 /* PropertyAccessExpression */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 191 /* VariableStatement */: - case 209 /* VariableDeclaration */: - case 225 /* ExportAssignment */: - case 202 /* ReturnStatement */: - case 180 /* ConditionalExpression */: - case 160 /* ArrayBindingPattern */: - case 159 /* ObjectBindingPattern */: - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - case 140 /* MethodSignature */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 136 /* Parameter */: - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 158 /* ParenthesizedType */: - case 168 /* TaggedTemplateExpression */: - case 176 /* AwaitExpression */: + case 195 /* ExpressionStatement */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 164 /* ArrayLiteralExpression */: + case 192 /* Block */: + case 219 /* ModuleBlock */: + case 165 /* ObjectLiteralExpression */: + case 155 /* TypeLiteral */: + case 157 /* TupleType */: + case 220 /* CaseBlock */: + case 242 /* DefaultClause */: + case 241 /* CaseClause */: + case 172 /* ParenthesizedExpression */: + case 166 /* PropertyAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 193 /* VariableStatement */: + case 211 /* VariableDeclaration */: + case 227 /* ExportAssignment */: + case 204 /* ReturnStatement */: + case 182 /* ConditionalExpression */: + case 162 /* ArrayBindingPattern */: + case 161 /* ObjectBindingPattern */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 142 /* MethodSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 138 /* Parameter */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 160 /* ParenthesizedType */: + case 170 /* TaggedTemplateExpression */: + case 178 /* AwaitExpression */: return true; } return false; @@ -41949,20 +42691,20 @@ var ts; return true; } switch (parent) { - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 197 /* ForStatement */: - case 194 /* IfStatement */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 141 /* MethodDeclaration */: - case 172 /* ArrowFunction */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - return child !== 190 /* Block */; + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 199 /* ForStatement */: + case 196 /* IfStatement */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 174 /* ArrowFunction */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + return child !== 192 /* Block */; default: return false; } @@ -42104,7 +42846,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(269 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); + var list = createNode(271 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -42123,7 +42865,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 133 /* FirstNode */) { + if (this.kind >= 135 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -42170,7 +42912,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 133 /* FirstNode */ ? child : child.getFirstToken(sourceFile); + return child.kind < 135 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -42178,7 +42920,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 133 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 135 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; })(); @@ -42227,7 +42969,7 @@ var ts; if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments - if (canUseParsedParamTagComments && declaration.kind === 136 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 138 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -42236,15 +42978,15 @@ var ts; }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 216 /* ModuleDeclaration */ && declaration.body.kind === 216 /* ModuleDeclaration */) { + if (declaration.kind === 218 /* ModuleDeclaration */ && declaration.body.kind === 218 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 216 /* ModuleDeclaration */ && declaration.parent.kind === 216 /* ModuleDeclaration */) { + while (declaration.kind === 218 /* ModuleDeclaration */ && declaration.parent.kind === 218 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 209 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 211 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); @@ -42588,9 +43330,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 134 /* ComputedPropertyName */) { + if (declaration.name.kind === 136 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 164 /* PropertyAccessExpression */) { + if (expr.kind === 166 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -42600,7 +43342,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 67 /* Identifier */ || + if (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { return node.text; @@ -42610,9 +43352,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -42632,60 +43374,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 215 /* EnumDeclaration */: - case 216 /* ModuleDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 228 /* ExportSpecifier */: - case 224 /* ImportSpecifier */: - case 219 /* ImportEqualsDeclaration */: - case 221 /* ImportClause */: - case 222 /* NamespaceImport */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 153 /* TypeLiteral */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 217 /* EnumDeclaration */: + case 218 /* ModuleDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 230 /* ExportSpecifier */: + case 226 /* ImportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 155 /* TypeLiteral */: addDeclaration(node); // fall through - case 142 /* Constructor */: - case 191 /* VariableStatement */: - case 210 /* VariableDeclarationList */: - case 159 /* ObjectBindingPattern */: - case 160 /* ArrayBindingPattern */: - case 217 /* ModuleBlock */: + case 144 /* Constructor */: + case 193 /* VariableStatement */: + case 212 /* VariableDeclarationList */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + case 219 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 190 /* Block */: + case 192 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 136 /* Parameter */: + case 138 /* Parameter */: // Only consider properties defined as constructor parameters if (!(node.flags & 112 /* AccessibilityModifier */)) { break; } // fall through - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 245 /* EnumMember */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 247 /* EnumMember */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: addDeclaration(node); break; - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -42697,7 +43439,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -42724,6 +43466,12 @@ var ts; HighlightSpanKind.reference = "reference"; HighlightSpanKind.writtenReference = "writtenReference"; })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); + (function (IndentStyle) { + IndentStyle[IndentStyle["None"] = 0] = "None"; + IndentStyle[IndentStyle["Block"] = 1] = "Block"; + IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; + })(ts.IndentStyle || (ts.IndentStyle = {})); + var IndentStyle = ts.IndentStyle; (function (SymbolDisplayPartKind) { SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; @@ -42901,16 +43649,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 171 /* FunctionExpression */) { + if (declaration.kind === 173 /* FunctionExpression */) { return true; } - if (declaration.kind !== 209 /* VariableDeclaration */ && declaration.kind !== 211 /* FunctionDeclaration */) { + if (declaration.kind !== 211 /* VariableDeclaration */ && declaration.kind !== 213 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { // Reached source file or module block - if (parent_8.kind === 246 /* SourceFile */ || parent_8.kind === 217 /* ModuleBlock */) { + if (parent_8.kind === 248 /* SourceFile */ || parent_8.kind === 219 /* ModuleBlock */) { return false; } } @@ -43047,8 +43795,8 @@ var ts; // We are not doing a full typecheck, we are not resolving the whole context, // so pass --noResolve to avoid reporting missing file errors. options.noResolve = true; - // Parse - var inputFileName = transpileOptions.fileName || "module.ts"; + // if jsx is specified then treat file as .tsx + var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); var sourceFile = ts.createSourceFile(inputFileName, input, options.target); if (transpileOptions.moduleName) { sourceFile.moduleName = transpileOptions.moduleName; @@ -43260,8 +44008,9 @@ var ts; }; } ts.createDocumentRegistry = createDocumentRegistry; - function preProcessFile(sourceText, readImportFiles) { + function preProcessFile(sourceText, readImportFiles, detectJavaScriptImports) { if (readImportFiles === void 0) { readImportFiles = true; } + if (detectJavaScriptImports === void 0) { detectJavaScriptImports = false; } var referencedFiles = []; var importedFiles = []; var ambientExternalModules; @@ -43295,125 +44044,75 @@ var ts; end: pos + importPath.length }); } - function processImport() { - scanner.setText(sourceText); - var token = scanner.scan(); - // Look for: - // import "mod"; - // import d from "mod" - // import {a as A } from "mod"; - // import * as NS from "mod" - // import d, {a, b as B} from "mod" - // import i = require("mod"); - // - // export * from "mod" - // export {a as b} from "mod" - // export import i = require("mod") - while (token !== 1 /* EndOfFileToken */) { - if (token === 120 /* DeclareKeyword */) { - // declare module "mod" - token = scanner.scan(); - if (token === 123 /* ModuleKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - recordAmbientExternalModule(); - continue; - } - } - } - else if (token === 87 /* ImportKeyword */) { + /** + * Returns true if at least one token was consumed from the stream + */ + function tryConsumeDeclare() { + var token = scanner.getToken(); + if (token === 122 /* DeclareKeyword */) { + // declare module "mod" + token = scanner.scan(); + if (token === 125 /* ModuleKeyword */) { token = scanner.scan(); if (token === 9 /* StringLiteral */) { - // import "mod"; - recordModuleName(); - continue; + recordAmbientExternalModule(); } - else { - if (token === 67 /* Identifier */ || ts.isKeyword(token)) { + } + return true; + } + return false; + } + /** + * Returns true if at least one token was consumed from the stream + */ + function tryConsumeImport() { + var token = scanner.getToken(); + if (token === 89 /* ImportKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import "mod"; + recordModuleName(); + return true; + } + else { + if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { token = scanner.scan(); - if (token === 131 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import d from "mod"; - recordModuleName(); - continue; - } - } - else if (token === 55 /* EqualsToken */) { - token = scanner.scan(); - if (token === 125 /* RequireKeyword */) { - token = scanner.scan(); - if (token === 17 /* OpenParenToken */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import i = require("mod"); - recordModuleName(); - continue; - } - } - } - } - else if (token === 24 /* CommaToken */) { - // consume comma and keep going - token = scanner.scan(); - } - else { - // unknown syntax - continue; + if (token === 9 /* StringLiteral */) { + // import d from "mod"; + recordModuleName(); + return true; } } - if (token === 15 /* OpenBraceToken */) { - token = scanner.scan(); - // consume "{ a as B, c, d as D}" clauses - while (token !== 16 /* CloseBraceToken */) { - token = scanner.scan(); - } - if (token === 16 /* CloseBraceToken */) { - token = scanner.scan(); - if (token === 131 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import {a as A} from "mod"; - // import d, {a, b as B} from "mod" - recordModuleName(); - } - } + else if (token === 56 /* EqualsToken */) { + if (tryConsumeRequireCall(/* skipCurrentToken */ true)) { + return true; } } - else if (token === 37 /* AsteriskToken */) { + else if (token === 24 /* CommaToken */) { + // consume comma and keep going token = scanner.scan(); - if (token === 114 /* AsKeyword */) { - token = scanner.scan(); - if (token === 67 /* Identifier */ || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 131 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import * as NS from "mod" - // import d, * as NS from "mod" - recordModuleName(); - } - } - } - } + } + else { + // unknown syntax + return true; } } - } - else if (token === 80 /* ExportKeyword */) { - token = scanner.scan(); if (token === 15 /* OpenBraceToken */) { token = scanner.scan(); // consume "{ a as B, c, d as D}" clauses - while (token !== 16 /* CloseBraceToken */) { + // make sure that it stops on EOF + while (token !== 16 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = scanner.scan(); } if (token === 16 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 131 /* FromKeyword */) { + if (token === 133 /* FromKeyword */) { token = scanner.scan(); if (token === 9 /* StringLiteral */) { - // export {a as A} from "mod"; - // export {a, b as B} from "mod" + // import {a as A} from "mod"; + // import d, {a, b as B} from "mod" recordModuleName(); } } @@ -43421,40 +44120,162 @@ var ts; } else if (token === 37 /* AsteriskToken */) { token = scanner.scan(); - if (token === 131 /* FromKeyword */) { + if (token === 116 /* AsKeyword */) { + token = scanner.scan(); + if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import * as NS from "mod" + // import d, * as NS from "mod" + recordModuleName(); + } + } + } + } + } + } + return true; + } + return false; + } + function tryConsumeExport() { + var token = scanner.getToken(); + if (token === 82 /* ExportKeyword */) { + token = scanner.scan(); + if (token === 15 /* OpenBraceToken */) { + token = scanner.scan(); + // consume "{ a as B, c, d as D}" clauses + // make sure it stops on EOF + while (token !== 16 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + token = scanner.scan(); + } + if (token === 16 /* CloseBraceToken */) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { token = scanner.scan(); if (token === 9 /* StringLiteral */) { - // export * from "mod" + // export {a as A} from "mod"; + // export {a, b as B} from "mod" recordModuleName(); } } } - else if (token === 87 /* ImportKeyword */) { + } + else if (token === 37 /* AsteriskToken */) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { token = scanner.scan(); - if (token === 67 /* Identifier */ || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 55 /* EqualsToken */) { - token = scanner.scan(); - if (token === 125 /* RequireKeyword */) { - token = scanner.scan(); - if (token === 17 /* OpenParenToken */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // export import i = require("mod"); - recordModuleName(); - } - } - } + if (token === 9 /* StringLiteral */) { + // export * from "mod" + recordModuleName(); + } + } + } + else if (token === 89 /* ImportKeyword */) { + token = scanner.scan(); + if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 56 /* EqualsToken */) { + if (tryConsumeRequireCall(/* skipCurrentToken */ true)) { + return true; } } } } + return true; + } + return false; + } + function tryConsumeRequireCall(skipCurrentToken) { + var token = skipCurrentToken ? scanner.scan() : scanner.getToken(); + if (token === 127 /* RequireKeyword */) { + token = scanner.scan(); + if (token === 17 /* OpenParenToken */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // require("mod"); + recordModuleName(); + } + } + return true; + } + return false; + } + function tryConsumeDefine() { + var token = scanner.getToken(); + if (token === 69 /* Identifier */ && scanner.getTokenValue() === "define") { + token = scanner.scan(); + if (token !== 17 /* OpenParenToken */) { + return true; + } + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // looks like define ("modname", ... - skip string literal and comma + token = scanner.scan(); + if (token === 24 /* CommaToken */) { + token = scanner.scan(); + } + else { + // unexpected token + return true; + } + } + // should be start of dependency list + if (token !== 19 /* OpenBracketToken */) { + return true; + } + // skip open bracket token = scanner.scan(); + var i = 0; + // scan until ']' or EOF + while (token !== 20 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + // record string literals as module names + if (token === 9 /* StringLiteral */) { + recordModuleName(); + i++; + } + token = scanner.scan(); + } + return true; + } + return false; + } + function processImports() { + scanner.setText(sourceText); + scanner.scan(); + // Look for: + // import "mod"; + // import d from "mod" + // import {a as A } from "mod"; + // import * as NS from "mod" + // import d, {a, b as B} from "mod" + // import i = require("mod"); + // + // export * from "mod" + // export {a as b} from "mod" + // export import i = require("mod") + // (for JavaScript files) require("mod") + while (true) { + if (scanner.getToken() === 1 /* EndOfFileToken */) { + break; + } + // check if at least one of alternative have moved scanner forward + if (tryConsumeDeclare() || + tryConsumeImport() || + tryConsumeExport() || + (detectJavaScriptImports && (tryConsumeRequireCall(/* skipCurrentToken */ false) || tryConsumeDefine()))) { + continue; + } + else { + scanner.scan(); + } } scanner.setText(undefined); } if (readImportFiles) { - processImport(); + processImports(); } processTripleSlashDirectives(); return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules }; @@ -43463,7 +44284,7 @@ var ts; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 205 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 207 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -43471,13 +44292,13 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 67 /* Identifier */ && - (node.parent.kind === 201 /* BreakStatement */ || node.parent.kind === 200 /* ContinueStatement */) && + return node.kind === 69 /* Identifier */ && + (node.parent.kind === 203 /* BreakStatement */ || node.parent.kind === 202 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 67 /* Identifier */ && - node.parent.kind === 205 /* LabeledStatement */ && + return node.kind === 69 /* Identifier */ && + node.parent.kind === 207 /* LabeledStatement */ && node.parent.label === node; } /** @@ -43485,7 +44306,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 205 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 207 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -43496,49 +44317,49 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 168 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 167 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 169 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 216 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 218 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 67 /* Identifier */ && + return node.kind === 69 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */ function isNameOfPropertyAssignment(node) { - return (node.kind === 67 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - (node.parent.kind === 243 /* PropertyAssignment */ || node.parent.kind === 244 /* ShorthandPropertyAssignment */) && node.parent.name === node; + return (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && + (node.parent.kind === 245 /* PropertyAssignment */ || node.parent.kind === 246 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 243 /* PropertyAssignment */: - case 245 /* EnumMember */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 216 /* ModuleDeclaration */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 245 /* PropertyAssignment */: + case 247 /* EnumMember */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 218 /* ModuleDeclaration */: return node.parent.name === node; - case 165 /* ElementAccessExpression */: + case 167 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } @@ -43597,7 +44418,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 68 /* FirstKeyword */; i <= 132 /* LastKeyword */; i++) { + for (var i = 70 /* FirstKeyword */; i <= 134 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -43612,17 +44433,17 @@ var ts; return undefined; } switch (node.kind) { - case 246 /* SourceFile */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 216 /* ModuleDeclaration */: + case 248 /* SourceFile */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 218 /* ModuleDeclaration */: return node; } } @@ -43630,38 +44451,38 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 216 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 212 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 213 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 214 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 215 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 209 /* VariableDeclaration */: + case 218 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 214 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 215 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 216 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 217 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 211 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 211 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 143 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 144 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 213 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 145 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 146 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 147 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 146 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 145 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 142 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 135 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 245 /* EnumMember */: return ScriptElementKind.variableElement; - case 136 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 219 /* ImportEqualsDeclaration */: - case 224 /* ImportSpecifier */: - case 221 /* ImportClause */: - case 228 /* ExportSpecifier */: - case 222 /* NamespaceImport */: + case 149 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 148 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 147 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 144 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 137 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 247 /* EnumMember */: return ScriptElementKind.variableElement; + case 138 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 221 /* ImportEqualsDeclaration */: + case 226 /* ImportSpecifier */: + case 223 /* ImportClause */: + case 230 /* ExportSpecifier */: + case 224 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -43885,7 +44706,7 @@ var ts; // For JavaScript files, we don't want to report the normal typescript semantic errors. // Instead, we just report errors for using TypeScript-only constructs from within a // JavaScript file. - if (ts.isJavaScript(fileName)) { + if (ts.isSourceFileJavaScript(targetSourceFile)) { return getJavaScriptSemanticDiagnostics(targetSourceFile); } // Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file. @@ -43907,44 +44728,44 @@ var ts; return false; } switch (node.kind) { - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 241 /* HeritageClause */: + case 243 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 104 /* ImplementsKeyword */) { + if (heritageClause.token === 106 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 171 /* FunctionExpression */: - case 211 /* FunctionDeclaration */: - case 172 /* ArrowFunction */: - case 211 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -43952,20 +44773,20 @@ var ts; return true; } break; - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 209 /* VariableDeclaration */: + case 211 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -43973,7 +44794,7 @@ var ts; return true; } break; - case 136 /* Parameter */: + case 138 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -43989,17 +44810,17 @@ var ts; return true; } break; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 169 /* TypeAssertionExpression */: + case 171 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 137 /* Decorator */: + case 139 /* Decorator */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -44025,18 +44846,18 @@ var ts; for (var _i = 0; _i < modifiers.length; _i++) { var modifier = modifiers[_i]; switch (modifier.kind) { - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 120 /* DeclareKeyword */: + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 122 /* DeclareKeyword */: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; // These are all legal modifiers. - case 111 /* StaticKeyword */: - case 80 /* ExportKeyword */: - case 72 /* ConstKeyword */: - case 75 /* DefaultKeyword */: - case 113 /* AbstractKeyword */: + case 113 /* StaticKeyword */: + case 82 /* ExportKeyword */: + case 74 /* ConstKeyword */: + case 77 /* DefaultKeyword */: + case 115 /* AbstractKeyword */: } } } @@ -44097,7 +44918,7 @@ var ts; var typeChecker = program.getTypeChecker(); var syntacticStart = new Date().getTime(); var sourceFile = getValidSourceFile(fileName); - var isJavaScriptFile = ts.isJavaScript(fileName); + var isJavaScriptFile = ts.isSourceFileJavaScript(sourceFile); var isJsDocTagName = false; var start = new Date().getTime(); var currentToken = ts.getTokenAtPosition(sourceFile, position); @@ -44122,9 +44943,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 267 /* JSDocTypeTag */: - case 265 /* JSDocParameterTag */: - case 266 /* JSDocReturnTag */: + case 269 /* JSDocTypeTag */: + case 267 /* JSDocParameterTag */: + case 268 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -44161,6 +44982,7 @@ var ts; var node = currentToken; var isRightOfDot = false; var isRightOfOpenTag = false; + var isStartingCloseTag = false; var location = ts.getTouchingPropertyName(sourceFile, position); if (contextToken) { // Bail out if this is a known invalid completion location @@ -44170,11 +44992,11 @@ var ts; } var parent_9 = contextToken.parent, kind = contextToken.kind; if (kind === 21 /* DotToken */) { - if (parent_9.kind === 164 /* PropertyAccessExpression */) { + if (parent_9.kind === 166 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_9.kind === 133 /* QualifiedName */) { + else if (parent_9.kind === 135 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -44184,9 +45006,14 @@ var ts; return undefined; } } - else if (kind === 25 /* LessThanToken */ && sourceFile.languageVariant === 1 /* JSX */) { - isRightOfOpenTag = true; - location = contextToken; + else if (sourceFile.languageVariant === 1 /* JSX */) { + if (kind === 25 /* LessThanToken */) { + isRightOfOpenTag = true; + location = contextToken; + } + else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 237 /* JsxClosingElement */) { + isStartingCloseTag = true; + } } } var semanticStart = new Date().getTime(); @@ -44207,6 +45034,12 @@ var ts; isMemberCompletion = true; isNewIdentifierLocation = false; } + else if (isStartingCloseTag) { + var tagName = contextToken.parent.parent.openingElement.tagName; + symbols = [typeChecker.getSymbolAtLocation(tagName)]; + isMemberCompletion = true; + isNewIdentifierLocation = false; + } else { // For JavaScript or TypeScript, if we're not after a dot, then just try to get the // global symbols in scope. These results should be valid for either language as @@ -44221,7 +45054,7 @@ var ts; // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */) { + if (node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */ || node.kind === 166 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -44277,7 +45110,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; - if ((jsxContainer.kind === 232 /* JsxSelfClosingElement */) || (jsxContainer.kind === 233 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 234 /* JsxSelfClosingElement */) || (jsxContainer.kind === 235 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -44343,49 +45176,64 @@ var ts; var start = new Date().getTime(); var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || isSolelyIdentifierDefinitionLocation(contextToken) || - isDotOfNumericLiteral(contextToken); + isDotOfNumericLiteral(contextToken) || + isInJsxText(contextToken); log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); return result; } + function isInJsxText(contextToken) { + if (contextToken.kind === 236 /* JsxText */) { + return true; + } + if (contextToken.kind === 27 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 235 /* JsxOpeningElement */) { + return true; + } + if (contextToken.parent.kind === 237 /* JsxClosingElement */ || contextToken.parent.kind === 234 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 233 /* JsxElement */; + } + } + return false; + } function isNewIdentifierDefinitionLocation(previousToken) { if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 24 /* CommaToken */: - return containingNodeKind === 166 /* CallExpression */ // func( a, | - || containingNodeKind === 142 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 167 /* NewExpression */ // new C(a, | - || containingNodeKind === 162 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 179 /* BinaryExpression */ // let x = (a, | - || containingNodeKind === 150 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 168 /* CallExpression */ // func( a, | + || containingNodeKind === 144 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 169 /* NewExpression */ // new C(a, | + || containingNodeKind === 164 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 181 /* BinaryExpression */ // let x = (a, | + || containingNodeKind === 152 /* FunctionType */; // var x: (s: string, list| case 17 /* OpenParenToken */: - return containingNodeKind === 166 /* CallExpression */ // func( | - || containingNodeKind === 142 /* Constructor */ // constructor( | - || containingNodeKind === 167 /* NewExpression */ // new C(a| - || containingNodeKind === 170 /* ParenthesizedExpression */ // let x = (a| - || containingNodeKind === 158 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 168 /* CallExpression */ // func( | + || containingNodeKind === 144 /* Constructor */ // constructor( | + || containingNodeKind === 169 /* NewExpression */ // new C(a| + || containingNodeKind === 172 /* ParenthesizedExpression */ // let x = (a| + || containingNodeKind === 160 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 19 /* OpenBracketToken */: - return containingNodeKind === 162 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 147 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 134 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 123 /* ModuleKeyword */: // module | - case 124 /* NamespaceKeyword */: + return containingNodeKind === 164 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 149 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 136 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 125 /* ModuleKeyword */: // module | + case 126 /* NamespaceKeyword */: return true; case 21 /* DotToken */: - return containingNodeKind === 216 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 218 /* ModuleDeclaration */; // module A.| case 15 /* OpenBraceToken */: - return containingNodeKind === 212 /* ClassDeclaration */; // class A{ | - case 55 /* EqualsToken */: - return containingNodeKind === 209 /* VariableDeclaration */ // let x = a| - || containingNodeKind === 179 /* BinaryExpression */; // x = a| + return containingNodeKind === 214 /* ClassDeclaration */; // class A{ | + case 56 /* EqualsToken */: + return containingNodeKind === 211 /* VariableDeclaration */ // let x = a| + || containingNodeKind === 181 /* BinaryExpression */; // x = a| case 12 /* TemplateHead */: - return containingNodeKind === 181 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 183 /* TemplateExpression */; // `aa ${| case 13 /* TemplateMiddle */: - return containingNodeKind === 188 /* TemplateSpan */; // `aa ${10} dd ${| - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - return containingNodeKind === 139 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 190 /* TemplateSpan */; // `aa ${10} dd ${| + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + return containingNodeKind === 141 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -44428,14 +45276,14 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 163 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 165 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 159 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 161 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -44481,9 +45329,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 223 /* NamedImports */ ? - 220 /* ImportDeclaration */ : - 226 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 225 /* NamedImports */ ? + 222 /* ImportDeclaration */ : + 228 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -44509,7 +45357,7 @@ var ts; case 15 /* OpenBraceToken */: // let x = { | case 24 /* CommaToken */: var parent_10 = contextToken.parent; - if (parent_10 && (parent_10.kind === 163 /* ObjectLiteralExpression */ || parent_10.kind === 159 /* ObjectBindingPattern */)) { + if (parent_10 && (parent_10.kind === 165 /* ObjectLiteralExpression */ || parent_10.kind === 161 /* ObjectBindingPattern */)) { return parent_10; } break; @@ -44527,8 +45375,8 @@ var ts; case 15 /* OpenBraceToken */: // import { | case 24 /* CommaToken */: switch (contextToken.parent.kind) { - case 223 /* NamedImports */: - case 227 /* NamedExports */: + case 225 /* NamedImports */: + case 229 /* NamedExports */: return contextToken.parent; } } @@ -44540,30 +45388,33 @@ var ts; var parent_11 = contextToken.parent; switch (contextToken.kind) { case 26 /* LessThanSlashToken */: - case 38 /* SlashToken */: - case 67 /* Identifier */: - case 236 /* JsxAttribute */: - case 237 /* JsxSpreadAttribute */: - if (parent_11 && (parent_11.kind === 232 /* JsxSelfClosingElement */ || parent_11.kind === 233 /* JsxOpeningElement */)) { + case 39 /* SlashToken */: + case 69 /* Identifier */: + case 238 /* JsxAttribute */: + case 239 /* JsxSpreadAttribute */: + if (parent_11 && (parent_11.kind === 234 /* JsxSelfClosingElement */ || parent_11.kind === 235 /* JsxOpeningElement */)) { return parent_11; } + else if (parent_11.kind === 238 /* JsxAttribute */) { + return parent_11.parent; + } break; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent_11 && ((parent_11.kind === 236 /* JsxAttribute */) || (parent_11.kind === 237 /* JsxSpreadAttribute */))) { + if (parent_11 && ((parent_11.kind === 238 /* JsxAttribute */) || (parent_11.kind === 239 /* JsxSpreadAttribute */))) { return parent_11.parent; } break; case 16 /* CloseBraceToken */: if (parent_11 && - parent_11.kind === 238 /* JsxExpression */ && + parent_11.kind === 240 /* JsxExpression */ && parent_11.parent && - (parent_11.parent.kind === 236 /* JsxAttribute */)) { + (parent_11.parent.kind === 238 /* JsxAttribute */)) { return parent_11.parent.parent; } - if (parent_11 && parent_11.kind === 237 /* JsxSpreadAttribute */) { + if (parent_11 && parent_11.kind === 239 /* JsxSpreadAttribute */) { return parent_11.parent; } break; @@ -44573,16 +45424,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: return true; } return false; @@ -44594,78 +45445,84 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 24 /* CommaToken */: - return containingNodeKind === 209 /* VariableDeclaration */ || - containingNodeKind === 210 /* VariableDeclarationList */ || - containingNodeKind === 191 /* VariableStatement */ || - containingNodeKind === 215 /* EnumDeclaration */ || + return containingNodeKind === 211 /* VariableDeclaration */ || + containingNodeKind === 212 /* VariableDeclarationList */ || + containingNodeKind === 193 /* VariableStatement */ || + containingNodeKind === 217 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 212 /* ClassDeclaration */ || - containingNodeKind === 184 /* ClassExpression */ || - containingNodeKind === 213 /* InterfaceDeclaration */ || - containingNodeKind === 160 /* ArrayBindingPattern */ || - containingNodeKind === 214 /* TypeAliasDeclaration */; // type Map, K, | + containingNodeKind === 214 /* ClassDeclaration */ || + containingNodeKind === 186 /* ClassExpression */ || + containingNodeKind === 215 /* InterfaceDeclaration */ || + containingNodeKind === 162 /* ArrayBindingPattern */ || + containingNodeKind === 216 /* TypeAliasDeclaration */; // type Map, K, | case 21 /* DotToken */: - return containingNodeKind === 160 /* ArrayBindingPattern */; // var [.| - case 53 /* ColonToken */: - return containingNodeKind === 161 /* BindingElement */; // var {x :html| + return containingNodeKind === 162 /* ArrayBindingPattern */; // var [.| + case 54 /* ColonToken */: + return containingNodeKind === 163 /* BindingElement */; // var {x :html| case 19 /* OpenBracketToken */: - return containingNodeKind === 160 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 162 /* ArrayBindingPattern */; // var [x| case 17 /* OpenParenToken */: - return containingNodeKind === 242 /* CatchClause */ || + return containingNodeKind === 244 /* CatchClause */ || isFunction(containingNodeKind); case 15 /* OpenBraceToken */: - return containingNodeKind === 215 /* EnumDeclaration */ || - containingNodeKind === 213 /* InterfaceDeclaration */ || - containingNodeKind === 153 /* TypeLiteral */; // let x : { | + return containingNodeKind === 217 /* EnumDeclaration */ || + containingNodeKind === 215 /* InterfaceDeclaration */ || + containingNodeKind === 155 /* TypeLiteral */; // let x : { | case 23 /* SemicolonToken */: - return containingNodeKind === 138 /* PropertySignature */ && + return containingNodeKind === 140 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 213 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 153 /* TypeLiteral */); // let x : { a; | + (contextToken.parent.parent.kind === 215 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 155 /* TypeLiteral */); // let x : { a; | case 25 /* LessThanToken */: - return containingNodeKind === 212 /* ClassDeclaration */ || - containingNodeKind === 184 /* ClassExpression */ || - containingNodeKind === 213 /* InterfaceDeclaration */ || - containingNodeKind === 214 /* TypeAliasDeclaration */ || + return containingNodeKind === 214 /* ClassDeclaration */ || + containingNodeKind === 186 /* ClassExpression */ || + containingNodeKind === 215 /* InterfaceDeclaration */ || + containingNodeKind === 216 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); - case 111 /* StaticKeyword */: - return containingNodeKind === 139 /* PropertyDeclaration */; + case 113 /* StaticKeyword */: + return containingNodeKind === 141 /* PropertyDeclaration */; case 22 /* DotDotDotToken */: - return containingNodeKind === 136 /* Parameter */ || + return containingNodeKind === 138 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 160 /* ArrayBindingPattern */); // var [...z| - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - return containingNodeKind === 136 /* Parameter */; - case 114 /* AsKeyword */: - containingNodeKind === 224 /* ImportSpecifier */ || - containingNodeKind === 228 /* ExportSpecifier */ || - containingNodeKind === 222 /* NamespaceImport */; - case 71 /* ClassKeyword */: - case 79 /* EnumKeyword */: - case 105 /* InterfaceKeyword */: - case 85 /* FunctionKeyword */: - case 100 /* VarKeyword */: - case 121 /* GetKeyword */: - case 127 /* SetKeyword */: - case 87 /* ImportKeyword */: - case 106 /* LetKeyword */: - case 72 /* ConstKeyword */: - case 112 /* YieldKeyword */: - case 130 /* TypeKeyword */: + contextToken.parent.parent.kind === 162 /* ArrayBindingPattern */); // var [...z| + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + return containingNodeKind === 138 /* Parameter */; + case 116 /* AsKeyword */: + return containingNodeKind === 226 /* ImportSpecifier */ || + containingNodeKind === 230 /* ExportSpecifier */ || + containingNodeKind === 224 /* NamespaceImport */; + case 73 /* ClassKeyword */: + case 81 /* EnumKeyword */: + case 107 /* InterfaceKeyword */: + case 87 /* FunctionKeyword */: + case 102 /* VarKeyword */: + case 123 /* GetKeyword */: + case 129 /* SetKeyword */: + case 89 /* ImportKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: + case 114 /* YieldKeyword */: + case 132 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. switch (contextToken.getText()) { + case "abstract": + case "async": case "class": - case "interface": + case "const": + case "declare": case "enum": case "function": - case "var": - case "static": + case "interface": case "let": - case "const": + case "private": + case "protected": + case "public": + case "static": + case "var": case "yield": return true; } @@ -44695,8 +45552,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_31 = element.propertyName || element.name; - exisingImportsOrExports[name_31.text] = true; + var name_32 = element.propertyName || element.name; + exisingImportsOrExports[name_32.text] = true; } if (ts.isEmpty(exisingImportsOrExports)) { return exportsOfModule; @@ -44717,9 +45574,9 @@ var ts; for (var _i = 0; _i < existingMembers.length; _i++) { var m = existingMembers[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 243 /* PropertyAssignment */ && - m.kind !== 244 /* ShorthandPropertyAssignment */ && - m.kind !== 161 /* BindingElement */) { + if (m.kind !== 245 /* PropertyAssignment */ && + m.kind !== 246 /* ShorthandPropertyAssignment */ && + m.kind !== 163 /* BindingElement */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -44727,7 +45584,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 161 /* BindingElement */ && m.propertyName) { + if (m.kind === 163 /* BindingElement */ && m.propertyName) { existingName = m.propertyName.text; } else { @@ -44754,7 +45611,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 236 /* JsxAttribute */) { + if (attr.kind === 238 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -44768,46 +45625,43 @@ var ts; return undefined; } var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; - var entries; if (isJsDocTagName) { // If the current position is a jsDoc tag name, only tag names should be provided for completion return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; } - if (isRightOfDot && ts.isJavaScript(fileName)) { - entries = getCompletionEntriesFromSymbols(symbols); - ts.addRange(entries, getJavaScriptCompletionEntries()); + var sourceFile = getValidSourceFile(fileName); + var entries = []; + if (isRightOfDot && ts.isSourceFileJavaScript(sourceFile)) { + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries); + ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, uniqueNames)); } else { if (!symbols || symbols.length === 0) { return undefined; } - entries = getCompletionEntriesFromSymbols(symbols); + getCompletionEntriesFromSymbols(symbols, entries); } // Add keywords if this is not a member completion list if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - function getJavaScriptCompletionEntries() { + function getJavaScriptCompletionEntries(sourceFile, uniqueNames) { var entries = []; - var allNames = {}; var target = program.getCompilerOptions().target; - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - var nameTable = getNameTable(sourceFile); - for (var name_32 in nameTable) { - if (!allNames[name_32]) { - allNames[name_32] = name_32; - var displayName = getCompletionEntryDisplayName(name_32, target, /*performCharacterChecks:*/ true); - if (displayName) { - var entry = { - name: displayName, - kind: ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; - entries.push(entry); - } + var nameTable = getNameTable(sourceFile); + for (var name_33 in nameTable) { + if (!uniqueNames[name_33]) { + uniqueNames[name_33] = name_33; + var displayName = getCompletionEntryDisplayName(name_33, target, /*performCharacterChecks:*/ true); + if (displayName) { + var entry = { + name: displayName, + kind: ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); } } } @@ -44845,25 +45699,24 @@ var ts; sortText: "0" }; } - function getCompletionEntriesFromSymbols(symbols) { + function getCompletionEntriesFromSymbols(symbols, entries) { var start = new Date().getTime(); - var entries = []; + var uniqueNames = {}; if (symbols) { - var nameToSymbol = {}; for (var _i = 0; _i < symbols.length; _i++) { var symbol = symbols[_i]; var entry = createCompletionEntry(symbol, location); if (entry) { var id = ts.escapeIdentifier(entry.name); - if (!ts.lookUp(nameToSymbol, id)) { + if (!ts.lookUp(uniqueNames, id)) { entries.push(entry); - nameToSymbol[id] = symbol; + uniqueNames[id] = id; } } } } log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start)); - return entries; + return uniqueNames; } } function getCompletionEntryDetails(fileName, position, entryName) { @@ -44906,7 +45759,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 186 /* ClassExpression */) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ScriptElementKind.enumElement; @@ -45008,7 +45861,7 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 164 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 166 /* PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -45017,7 +45870,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression; - if (location.kind === 166 /* CallExpression */ || location.kind === 167 /* NewExpression */) { + if (location.kind === 168 /* CallExpression */ || location.kind === 169 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -45030,10 +45883,11 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 167 /* NewExpression */ || callExpression.expression.kind === 93 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 169 /* NewExpression */ || callExpression.expression.kind === 95 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); - if (!ts.contains(allSignatures, signature.target || signature)) { - // Get the first signature if there + if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { + // Get the first signature if there is one -- allSignatures may contain + // either the original signature or its target, so check for either signature = allSignatures.length ? allSignatures[0] : undefined; } if (signature) { @@ -45047,7 +45901,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(90 /* NewKeyword */)); + displayParts.push(ts.keywordPart(92 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -45063,10 +45917,10 @@ var ts; case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(53 /* ColonToken */)); + displayParts.push(ts.punctuationPart(54 /* ColonToken */)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(90 /* NewKeyword */)); + displayParts.push(ts.keywordPart(92 /* NewKeyword */)); displayParts.push(ts.spacePart()); } if (!(type.flags & 65536 /* Anonymous */)) { @@ -45082,24 +45936,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 119 /* ConstructorKeyword */ && location.parent.kind === 142 /* Constructor */)) { + (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 144 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 142 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 144 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 142 /* Constructor */) { + if (functionDeclaration.kind === 144 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 145 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 147 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -45108,7 +45962,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 186 /* ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class @@ -45116,7 +45970,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(71 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(73 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -45124,37 +45978,37 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(105 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(107 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(130 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(132 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55 /* EqualsToken */)); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384 /* Enum */) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(72 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(74 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(79 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(81 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 216 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 67 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 124 /* NamespaceKeyword */ : 123 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 218 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 69 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 126 /* NamespaceKeyword */ : 125 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -45166,7 +46020,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(88 /* InKeyword */)); + displayParts.push(ts.keywordPart(90 /* InKeyword */)); displayParts.push(ts.spacePart()); if (symbol.parent) { // Class/Interface type parameter @@ -45177,13 +46031,13 @@ var ts; // Method/function type parameter var container = ts.getContainingFunction(location); if (container) { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 146 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(90 /* NewKeyword */)); + if (signatureDeclaration.kind === 148 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(92 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 145 /* CallSignature */ && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 147 /* CallSignature */ && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -45192,8 +46046,8 @@ var ts; // Type aliash type parameter // For example // type list = T[]; // Both T will go through same code path - var declaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; - displayParts.push(ts.keywordPart(130 /* TypeKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).parent; + displayParts.push(ts.keywordPart(132 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -45203,11 +46057,11 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 245 /* EnumMember */) { + if (declaration.kind === 247 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55 /* EqualsToken */)); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } @@ -45215,17 +46069,17 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(87 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(89 /* ImportKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 219 /* ImportEqualsDeclaration */) { + if (declaration.kind === 221 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55 /* EqualsToken */)); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(125 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(127 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); @@ -45234,7 +46088,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55 /* EqualsToken */)); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -45251,7 +46105,7 @@ var ts; if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 /* Variable */ || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(53 /* ColonToken */)); + displayParts.push(ts.punctuationPart(54 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -45351,11 +46205,11 @@ var ts; if (!symbol) { // Try getting just type at this position and show switch (node.kind) { - case 67 /* Identifier */: - case 164 /* PropertyAccessExpression */: - case 133 /* QualifiedName */: - case 95 /* ThisKeyword */: - case 93 /* SuperKeyword */: + case 69 /* Identifier */: + case 166 /* PropertyAccessExpression */: + case 135 /* QualifiedName */: + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -45408,7 +46262,7 @@ var ts; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (isNewExpressionTarget(location) || location.kind === 119 /* ConstructorKeyword */) { + if (isNewExpressionTarget(location) || location.kind === 121 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { // Find the first class-like declaration and try to get the construct signature. for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { @@ -45433,8 +46287,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 142 /* Constructor */) || - (!selectConstructors && (d.kind === 211 /* FunctionDeclaration */ || d.kind === 141 /* MethodDeclaration */ || d.kind === 140 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 144 /* Constructor */) || + (!selectConstructors && (d.kind === 213 /* FunctionDeclaration */ || d.kind === 143 /* MethodDeclaration */ || d.kind === 142 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -45494,7 +46348,7 @@ var ts; // to jump to the implementation directly. if (symbol.flags & 8388608 /* Alias */) { var declaration = symbol.declarations[0]; - if (node.kind === 67 /* Identifier */ && node.parent === declaration) { + if (node.kind === 69 /* Identifier */ && node.parent === declaration) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -45503,7 +46357,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 244 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 246 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -45577,9 +46431,9 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 67 /* Identifier */ || - node.kind === 95 /* ThisKeyword */ || - node.kind === 93 /* SuperKeyword */ || + if (node.kind === 69 /* Identifier */ || + node.kind === 97 /* ThisKeyword */ || + node.kind === 95 /* SuperKeyword */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false); @@ -45630,77 +46484,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 86 /* IfKeyword */: - case 78 /* ElseKeyword */: - if (hasKind(node.parent, 194 /* IfStatement */)) { + case 88 /* IfKeyword */: + case 80 /* ElseKeyword */: + if (hasKind(node.parent, 196 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; - case 92 /* ReturnKeyword */: - if (hasKind(node.parent, 202 /* ReturnStatement */)) { + case 94 /* ReturnKeyword */: + if (hasKind(node.parent, 204 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; - case 96 /* ThrowKeyword */: - if (hasKind(node.parent, 206 /* ThrowStatement */)) { + case 98 /* ThrowKeyword */: + if (hasKind(node.parent, 208 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; - case 70 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 207 /* TryStatement */)) { + case 72 /* CatchKeyword */: + if (hasKind(parent(parent(node)), 209 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 98 /* TryKeyword */: - case 83 /* FinallyKeyword */: - if (hasKind(parent(node), 207 /* TryStatement */)) { + case 100 /* TryKeyword */: + case 85 /* FinallyKeyword */: + if (hasKind(parent(node), 209 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 94 /* SwitchKeyword */: - if (hasKind(node.parent, 204 /* SwitchStatement */)) { + case 96 /* SwitchKeyword */: + if (hasKind(node.parent, 206 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 69 /* CaseKeyword */: - case 75 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 204 /* SwitchStatement */)) { + case 71 /* CaseKeyword */: + case 77 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 206 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 68 /* BreakKeyword */: - case 73 /* ContinueKeyword */: - if (hasKind(node.parent, 201 /* BreakStatement */) || hasKind(node.parent, 200 /* ContinueStatement */)) { + case 70 /* BreakKeyword */: + case 75 /* ContinueKeyword */: + if (hasKind(node.parent, 203 /* BreakStatement */) || hasKind(node.parent, 202 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 84 /* ForKeyword */: - if (hasKind(node.parent, 197 /* ForStatement */) || - hasKind(node.parent, 198 /* ForInStatement */) || - hasKind(node.parent, 199 /* ForOfStatement */)) { + case 86 /* ForKeyword */: + if (hasKind(node.parent, 199 /* ForStatement */) || + hasKind(node.parent, 200 /* ForInStatement */) || + hasKind(node.parent, 201 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 102 /* WhileKeyword */: - case 77 /* DoKeyword */: - if (hasKind(node.parent, 196 /* WhileStatement */) || hasKind(node.parent, 195 /* DoStatement */)) { + case 104 /* WhileKeyword */: + case 79 /* DoKeyword */: + if (hasKind(node.parent, 198 /* WhileStatement */) || hasKind(node.parent, 197 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 119 /* ConstructorKeyword */: - if (hasKind(node.parent, 142 /* Constructor */)) { + case 121 /* ConstructorKeyword */: + if (hasKind(node.parent, 144 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; - case 121 /* GetKeyword */: - case 127 /* SetKeyword */: - if (hasKind(node.parent, 143 /* GetAccessor */) || hasKind(node.parent, 144 /* SetAccessor */)) { + case 123 /* GetKeyword */: + case 129 /* SetKeyword */: + if (hasKind(node.parent, 145 /* GetAccessor */) || hasKind(node.parent, 146 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 191 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 193 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -45716,10 +46570,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 206 /* ThrowStatement */) { + if (node.kind === 208 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 207 /* TryStatement */) { + else if (node.kind === 209 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -45748,12 +46602,12 @@ var ts; var child = throwStatement; while (child.parent) { var parent_12 = child.parent; - if (ts.isFunctionBlock(parent_12) || parent_12.kind === 246 /* SourceFile */) { + if (ts.isFunctionBlock(parent_12) || parent_12.kind === 248 /* SourceFile */) { return parent_12; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_12.kind === 207 /* TryStatement */) { + if (parent_12.kind === 209 /* TryStatement */) { var tryStatement = parent_12; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; @@ -45768,7 +46622,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 201 /* BreakStatement */ || node.kind === 200 /* ContinueStatement */) { + if (node.kind === 203 /* BreakStatement */ || node.kind === 202 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -45784,16 +46638,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 204 /* SwitchStatement */: - if (statement.kind === 200 /* ContinueStatement */) { + case 206 /* SwitchStatement */: + if (statement.kind === 202 /* ContinueStatement */) { continue; } // Fall through. - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 196 /* WhileStatement */: - case 195 /* DoStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 198 /* WhileStatement */: + case 197 /* DoStatement */: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -45812,24 +46666,24 @@ var ts; var container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 212 /* ClassDeclaration */ || - container.kind === 184 /* ClassExpression */ || - (declaration.kind === 136 /* Parameter */ && hasKind(container, 142 /* Constructor */)))) { + if (!(container.kind === 214 /* ClassDeclaration */ || + container.kind === 186 /* ClassExpression */ || + (declaration.kind === 138 /* Parameter */ && hasKind(container, 144 /* Constructor */)))) { return undefined; } } - else if (modifier === 111 /* StaticKeyword */) { - if (!(container.kind === 212 /* ClassDeclaration */ || container.kind === 184 /* ClassExpression */)) { + else if (modifier === 113 /* StaticKeyword */) { + if (!(container.kind === 214 /* ClassDeclaration */ || container.kind === 186 /* ClassExpression */)) { return undefined; } } - else if (modifier === 80 /* ExportKeyword */ || modifier === 120 /* DeclareKeyword */) { - if (!(container.kind === 217 /* ModuleBlock */ || container.kind === 246 /* SourceFile */)) { + else if (modifier === 82 /* ExportKeyword */ || modifier === 122 /* DeclareKeyword */) { + if (!(container.kind === 219 /* ModuleBlock */ || container.kind === 248 /* SourceFile */)) { return undefined; } } - else if (modifier === 113 /* AbstractKeyword */) { - if (!(container.kind === 212 /* ClassDeclaration */ || declaration.kind === 212 /* ClassDeclaration */)) { + else if (modifier === 115 /* AbstractKeyword */) { + if (!(container.kind === 214 /* ClassDeclaration */ || declaration.kind === 214 /* ClassDeclaration */)) { return undefined; } } @@ -45841,8 +46695,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 217 /* ModuleBlock */: - case 246 /* SourceFile */: + case 219 /* ModuleBlock */: + case 248 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 256 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -45851,17 +46705,17 @@ var ts; nodes = container.statements; } break; - case 142 /* Constructor */: + case 144 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. if (modifierFlag & 112 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 142 /* Constructor */ && member; + return member.kind === 144 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -45882,19 +46736,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 110 /* PublicKeyword */: + case 112 /* PublicKeyword */: return 16 /* Public */; - case 108 /* PrivateKeyword */: + case 110 /* PrivateKeyword */: return 32 /* Private */; - case 109 /* ProtectedKeyword */: + case 111 /* ProtectedKeyword */: return 64 /* Protected */; - case 111 /* StaticKeyword */: + case 113 /* StaticKeyword */: return 128 /* Static */; - case 80 /* ExportKeyword */: + case 82 /* ExportKeyword */: return 1 /* Export */; - case 120 /* DeclareKeyword */: + case 122 /* DeclareKeyword */: return 2 /* Ambient */; - case 113 /* AbstractKeyword */: + case 115 /* AbstractKeyword */: return 256 /* Abstract */; default: ts.Debug.fail(); @@ -45914,13 +46768,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 143 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 144 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 145 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 146 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 121 /* GetKeyword */, 127 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 123 /* GetKeyword */, 129 /* SetKeyword */); }); } } } @@ -45929,19 +46783,19 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 119 /* ConstructorKeyword */); + return pushKeywordIf(keywords, token, 121 /* ConstructorKeyword */); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 84 /* ForKeyword */, 102 /* WhileKeyword */, 77 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86 /* ForKeyword */, 104 /* WhileKeyword */, 79 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 195 /* DoStatement */) { + if (loopNode.kind === 197 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 102 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 104 /* WhileKeyword */)) { break; } } @@ -45950,7 +46804,7 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */, 73 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */, 75 /* ContinueKeyword */); } }); return ts.map(keywords, getHighlightSpanForNode); @@ -45959,13 +46813,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 204 /* SwitchStatement */: + case 206 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -45973,14 +46827,14 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 94 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 96 /* SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 69 /* CaseKeyword */, 75 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 71 /* CaseKeyword */, 77 /* DefaultKeyword */); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */); } }); }); @@ -45988,13 +46842,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 98 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 100 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 70 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 83 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 85 /* FinallyKeyword */); } return ts.map(keywords, getHighlightSpanForNode); } @@ -46005,13 +46859,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); }); } return ts.map(keywords, getHighlightSpanForNode); @@ -46019,36 +46873,36 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 190 /* Block */))) { + if (!(func && hasKind(func.body, 192 /* Block */))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 194 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 196 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 86 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 88 /* IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 78 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 80 /* ElseKeyword */)) { break; } } - if (!hasKind(ifStatement.elseStatement, 194 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 196 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -46057,7 +46911,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 78 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 80 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombindElseAndIf = true; @@ -46139,7 +46993,7 @@ var ts; if (!node) { return undefined; } - if (node.kind !== 67 /* Identifier */ && + if (node.kind !== 69 /* Identifier */ && // TODO (drosen): This should be enabled in a later release - currently breaks rename. //node.kind !== SyntaxKind.ThisKeyword && //node.kind !== SyntaxKind.SuperKeyword && @@ -46147,7 +47001,7 @@ var ts; !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */); + ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */); return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { @@ -46165,10 +47019,10 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 95 /* ThisKeyword */) { + if (node.kind === 97 /* ThisKeyword */) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 93 /* SuperKeyword */) { + if (node.kind === 95 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } var symbol = typeChecker.getSymbolAtLocation(node); @@ -46228,7 +47082,7 @@ var ts; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 228 /* ExportSpecifier */; + return declaration.kind === 226 /* ImportSpecifier */ || declaration.kind === 230 /* ExportSpecifier */; }); } function getInternedName(symbol, location, declarations) { @@ -46255,14 +47109,14 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 171 /* FunctionExpression */ || valueDeclaration.kind === 184 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 173 /* FunctionExpression */ || valueDeclaration.kind === 186 /* ClassExpression */)) { return valueDeclaration; } // If this is private property or method, the scope is the containing class if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 212 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 214 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -46288,7 +47142,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 246 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 248 /* SourceFile */ && !ts.isExternalModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -46359,7 +47213,7 @@ var ts; if (node) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: return node.getWidth() === searchSymbolName.length; case 9 /* StringLiteral */: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || @@ -46461,13 +47315,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -46480,7 +47334,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 93 /* SuperKeyword */) { + if (!node || node.kind !== 95 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*includeFunctions*/ false); @@ -46499,27 +47353,27 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 246 /* SourceFile */: + case 248 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. @@ -46528,7 +47382,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 246 /* SourceFile */) { + if (searchSpaceNode.kind === 248 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -46554,33 +47408,33 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 95 /* ThisKeyword */) { + if (!node || node.kind !== 97 /* ThisKeyword */) { return; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 171 /* FunctionExpression */: - case 211 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 184 /* ClassExpression */: - case 212 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 246 /* SourceFile */: - if (container.kind === 246 /* SourceFile */ && !ts.isExternalModule(container)) { + case 248 /* SourceFile */: + if (container.kind === 248 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -46634,11 +47488,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 212 /* ClassDeclaration */) { + if (declaration.kind === 214 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 213 /* InterfaceDeclaration */) { + else if (declaration.kind === 215 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -46699,19 +47553,19 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_33 = node.text; + var name_34 = node.text; if (contextualType) { if (contextualType.flags & 16384 /* Union */) { // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) // if not, search the constituent types for the property - var unionProperty = contextualType.getProperty(name_33); + var unionProperty = contextualType.getProperty(name_34); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_33); + var symbol = t.getProperty(name_34); if (symbol) { result_4.push(symbol); } @@ -46720,7 +47574,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_33); + var symbol_1 = contextualType.getProperty(name_34); if (symbol_1) { return [symbol_1]; } @@ -46773,17 +47627,17 @@ var ts; } /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccess(node) { - if (node.kind === 67 /* Identifier */ && ts.isDeclarationName(node)) { + if (node.kind === 69 /* Identifier */ && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 178 /* PostfixUnaryExpression */ || parent.kind === 177 /* PrefixUnaryExpression */) { + if (parent.kind === 180 /* PostfixUnaryExpression */ || parent.kind === 179 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 179 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 181 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; - return 55 /* FirstAssignment */ <= operator && operator <= 66 /* LastAssignment */; + return 56 /* FirstAssignment */ <= operator && operator <= 68 /* LastAssignment */; } } return false; @@ -46815,33 +47669,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 136 /* Parameter */: - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 243 /* PropertyAssignment */: - case 244 /* ShorthandPropertyAssignment */: - case 245 /* EnumMember */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 242 /* CatchClause */: + case 138 /* Parameter */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 245 /* PropertyAssignment */: + case 246 /* ShorthandPropertyAssignment */: + case 247 /* EnumMember */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 244 /* CatchClause */: return 1 /* Value */; - case 135 /* TypeParameter */: - case 213 /* InterfaceDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 153 /* TypeLiteral */: + case 137 /* TypeParameter */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 155 /* TypeLiteral */: return 2 /* Type */; - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: if (node.name.kind === 9 /* StringLiteral */) { return 4 /* Namespace */ | 1 /* Value */; } @@ -46851,15 +47705,15 @@ var ts; else { return 4 /* Namespace */; } - case 223 /* NamedImports */: - case 224 /* ImportSpecifier */: - case 219 /* ImportEqualsDeclaration */: - case 220 /* ImportDeclaration */: - case 225 /* ExportAssignment */: - case 226 /* ExportDeclaration */: + case 225 /* NamedImports */: + case 226 /* ImportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 222 /* ImportDeclaration */: + case 227 /* ExportAssignment */: + case 228 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 246 /* SourceFile */: + case 248 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -46869,8 +47723,9 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 149 /* TypeReference */ || - (node.parent.kind === 186 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); + return node.parent.kind === 151 /* TypeReference */ || + (node.parent.kind === 188 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + node.kind === 97 /* ThisKeyword */ && !ts.isExpression(node); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -46878,50 +47733,50 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 164 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 164 /* PropertyAccessExpression */) { + if (root.parent.kind === 166 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 166 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 186 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 241 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 188 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 243 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 212 /* ClassDeclaration */ && root.parent.parent.token === 104 /* ImplementsKeyword */) || - (decl.kind === 213 /* InterfaceDeclaration */ && root.parent.parent.token === 81 /* ExtendsKeyword */); + return (decl.kind === 214 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) || + (decl.kind === 215 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 133 /* QualifiedName */) { - while (root.parent && root.parent.kind === 133 /* QualifiedName */) { + if (root.parent.kind === 135 /* QualifiedName */) { + while (root.parent && root.parent.kind === 135 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 149 /* TypeReference */ && !isLastClause; + return root.parent.kind === 151 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 133 /* QualifiedName */) { + while (node.parent.kind === 135 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 67 /* Identifier */); + ts.Debug.assert(node.kind === 69 /* Identifier */); // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 133 /* QualifiedName */ && + if (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 219 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 221 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 225 /* ExportAssignment */) { + if (node.parent.kind === 227 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -46961,15 +47816,15 @@ var ts; return; } switch (node.kind) { - case 164 /* PropertyAccessExpression */: - case 133 /* QualifiedName */: + case 166 /* PropertyAccessExpression */: + case 135 /* QualifiedName */: case 9 /* StringLiteral */: - case 82 /* FalseKeyword */: - case 97 /* TrueKeyword */: - case 91 /* NullKeyword */: - case 93 /* SuperKeyword */: - case 95 /* ThisKeyword */: - case 67 /* Identifier */: + case 84 /* FalseKeyword */: + case 99 /* TrueKeyword */: + case 93 /* NullKeyword */: + case 95 /* SuperKeyword */: + case 97 /* ThisKeyword */: + case 69 /* Identifier */: break; // Cant create the text span default: @@ -46985,7 +47840,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 216 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 218 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -47026,10 +47881,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 216 /* ModuleDeclaration */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 211 /* FunctionDeclaration */: + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -47083,7 +47938,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 216 /* ModuleDeclaration */ && + return declaration.kind === 218 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -47093,7 +47948,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(kind); - if (kind === 67 /* Identifier */ && !ts.nodeIsMissing(node)) { + if (kind === 69 /* Identifier */ && !ts.nodeIsMissing(node)) { var identifier = node; // Only bother calling into the typechecker if this is an identifier that // could possibly resolve to a type name. This makes classification run @@ -47238,16 +48093,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 265 /* JSDocParameterTag */: + case 267 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 268 /* JSDocTemplateTag */: + case 270 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 267 /* JSDocTypeTag */: + case 269 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 266 /* JSDocReturnTag */: + case 268 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -47336,18 +48191,18 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 55 /* EqualsToken */) { + if (tokenKind === 56 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 209 /* VariableDeclaration */ || - token.parent.kind === 139 /* PropertyDeclaration */ || - token.parent.kind === 136 /* Parameter */) { + if (token.parent.kind === 211 /* VariableDeclaration */ || + token.parent.kind === 141 /* PropertyDeclaration */ || + token.parent.kind === 138 /* Parameter */) { return 5 /* operator */; } } - if (token.parent.kind === 179 /* BinaryExpression */ || - token.parent.kind === 177 /* PrefixUnaryExpression */ || - token.parent.kind === 178 /* PostfixUnaryExpression */ || - token.parent.kind === 180 /* ConditionalExpression */) { + if (token.parent.kind === 181 /* BinaryExpression */ || + token.parent.kind === 179 /* PrefixUnaryExpression */ || + token.parent.kind === 180 /* PostfixUnaryExpression */ || + token.parent.kind === 182 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -47367,35 +48222,35 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 67 /* Identifier */) { + else if (tokenKind === 69 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 135 /* TypeParameter */: + case 137 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 136 /* Parameter */: + case 138 /* Parameter */: if (token.parent.name === token) { return 17 /* parameterName */; } @@ -47507,8 +48362,12 @@ var ts; * Checks if position points to a valid position to add JSDoc comments, and if so, * returns the appropriate template. Otherwise returns an empty string. * Valid positions are - * - outside of comments, statements, and expressions, and - * - preceding a function declaration. + * - outside of comments, statements, and expressions, and + * - preceding a: + * - function/constructor/method declaration + * - class declarations + * - variable statements + * - namespace declarations * * Hosts should ideally check that: * - The line is all whitespace up to 'position' before performing the insertion. @@ -47532,23 +48391,48 @@ var ts; return undefined; } // TODO: add support for: - // - methods - // - constructors - // - class decls - var containingFunction = ts.getAncestor(tokenAtPos, 211 /* FunctionDeclaration */); - if (!containingFunction || containingFunction.getStart() < position) { + // - enums/enum members + // - interfaces + // - property declarations + // - potentially property assignments + var commentOwner; + findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { + switch (commentOwner.kind) { + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 144 /* Constructor */: + case 214 /* ClassDeclaration */: + case 193 /* VariableStatement */: + break findOwner; + case 248 /* SourceFile */: + return undefined; + case 218 /* ModuleDeclaration */: + // If in walking up the tree, we hit a a nested namespace declaration, + // then we must be somewhere within a dotted namespace name; however we don't + // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. + if (commentOwner.parent.kind === 218 /* ModuleDeclaration */) { + return undefined; + } + break findOwner; + } + } + if (!commentOwner || commentOwner.getStart() < position) { return undefined; } - var parameters = containingFunction.parameters; + var parameters = getParametersForJsDocOwningNode(commentOwner); var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); // TODO: call a helper method instead once PR #4133 gets merged in. var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; - var docParams = parameters.reduce(function (prev, cur, index) { - return prev + - indentationStr + " * @param " + (cur.name.kind === 67 /* Identifier */ ? cur.name.text : "param" + index) + newLine; - }, ""); + var docParams = ""; + for (var i = 0, numParams = parameters.length; i < numParams; i++) { + var currentName = parameters[i].name; + var paramName = currentName.kind === 69 /* Identifier */ ? + currentName.text : + "param" + i; + docParams += indentationStr + " * @param " + paramName + newLine; + } // A doc comment consists of the following // * The opening comment line // * the first line (without a param) for the object's untagged info (this is also where the caret ends up) @@ -47564,6 +48448,46 @@ var ts; (tokenStart === position ? newLine + indentationStr : ""); return { newText: result, caretOffset: preamble.length }; } + function getParametersForJsDocOwningNode(commentOwner) { + if (ts.isFunctionLike(commentOwner)) { + return commentOwner.parameters; + } + if (commentOwner.kind === 193 /* VariableStatement */) { + var varStatement = commentOwner; + var varDeclarations = varStatement.declarationList.declarations; + if (varDeclarations.length === 1 && varDeclarations[0].initializer) { + return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); + } + } + return emptyArray; + } + /** + * Digs into an an initializer or RHS operand of an assignment operation + * to get the parameters of an apt signature corresponding to a + * function expression or a class expression. + * + * @param rightHandSide the expression which may contain an appropriate set of parameters + * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. + */ + function getParametersFromRightHandSideOfAssignment(rightHandSide) { + while (rightHandSide.kind === 172 /* ParenthesizedExpression */) { + rightHandSide = rightHandSide.expression; + } + switch (rightHandSide.kind) { + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + return rightHandSide.parameters; + case 186 /* ClassExpression */: + for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.kind === 144 /* Constructor */) { + return member.parameters; + } + } + break; + } + return emptyArray; + } function getTodoComments(fileName, descriptors) { // Note: while getting todo comments seems like a syntactic operation, we actually // treat it as a semantic operation here. This is because we expect our host to call @@ -47694,7 +48618,7 @@ var ts; var typeChecker = program.getTypeChecker(); var node = ts.getTouchingWord(sourceFile, position); // Can only rename an identifier. - if (node && node.kind === 67 /* Identifier */) { + if (node && node.kind === 69 /* Identifier */) { var symbol = typeChecker.getSymbolAtLocation(node); // Only allow a symbol to be renamed if it actually has at least one declaration. if (symbol) { @@ -47795,7 +48719,7 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: nameTable[node.text] = node.text; break; case 9 /* StringLiteral */: @@ -47805,7 +48729,7 @@ var ts; // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 230 /* ExternalModuleReference */ || + node.parent.kind === 232 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -47818,7 +48742,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 165 /* ElementAccessExpression */ && + node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier @@ -47829,18 +48753,18 @@ var ts; /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = []; - noRegexTable[67 /* Identifier */] = true; + noRegexTable[69 /* Identifier */] = true; noRegexTable[9 /* StringLiteral */] = true; noRegexTable[8 /* NumericLiteral */] = true; noRegexTable[10 /* RegularExpressionLiteral */] = true; - noRegexTable[95 /* ThisKeyword */] = true; - noRegexTable[40 /* PlusPlusToken */] = true; - noRegexTable[41 /* MinusMinusToken */] = true; + noRegexTable[97 /* ThisKeyword */] = true; + noRegexTable[41 /* PlusPlusToken */] = true; + noRegexTable[42 /* MinusMinusToken */] = true; noRegexTable[18 /* CloseParenToken */] = true; noRegexTable[20 /* CloseBracketToken */] = true; noRegexTable[16 /* CloseBraceToken */] = true; - noRegexTable[97 /* TrueKeyword */] = true; - noRegexTable[82 /* FalseKeyword */] = true; + noRegexTable[99 /* TrueKeyword */] = true; + noRegexTable[84 /* FalseKeyword */] = true; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -47865,10 +48789,10 @@ var ts; /** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */ function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 121 /* GetKeyword */ || - keyword2 === 127 /* SetKeyword */ || - keyword2 === 119 /* ConstructorKeyword */ || - keyword2 === 111 /* StaticKeyword */) { + if (keyword2 === 123 /* GetKeyword */ || + keyword2 === 129 /* SetKeyword */ || + keyword2 === 121 /* ConstructorKeyword */ || + keyword2 === 113 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". // These are all legal. return true; @@ -47998,22 +48922,22 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { + if ((token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { if (scanner.reScanSlashToken() === 10 /* RegularExpressionLiteral */) { token = 10 /* RegularExpressionLiteral */; } } else if (lastNonTriviaToken === 21 /* DotToken */ && isKeyword(token)) { - token = 67 /* Identifier */; + token = 69 /* Identifier */; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 67 /* Identifier */; + token = 69 /* Identifier */; } - else if (lastNonTriviaToken === 67 /* Identifier */ && + else if (lastNonTriviaToken === 69 /* Identifier */ && token === 25 /* LessThanToken */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. @@ -48024,16 +48948,16 @@ var ts; // generic entity is complete. angleBracketStack--; } - else if (token === 115 /* AnyKeyword */ || - token === 128 /* StringKeyword */ || - token === 126 /* NumberKeyword */ || - token === 118 /* BooleanKeyword */ || - token === 129 /* SymbolKeyword */) { + else if (token === 117 /* AnyKeyword */ || + token === 130 /* StringKeyword */ || + token === 128 /* NumberKeyword */ || + token === 120 /* BooleanKeyword */ || + token === 131 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 67 /* Identifier */; + token = 69 /* Identifier */; } } else if (token === 12 /* TemplateHead */) { @@ -48145,40 +49069,41 @@ var ts; function isBinaryExpressionOperatorToken(token) { switch (token) { case 37 /* AsteriskToken */: - case 38 /* SlashToken */: - case 39 /* PercentToken */: + case 39 /* SlashToken */: + case 40 /* PercentToken */: case 35 /* PlusToken */: case 36 /* MinusToken */: - case 42 /* LessThanLessThanToken */: - case 43 /* GreaterThanGreaterThanToken */: - case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 43 /* LessThanLessThanToken */: + case 44 /* GreaterThanGreaterThanToken */: + case 45 /* GreaterThanGreaterThanGreaterThanToken */: case 25 /* LessThanToken */: case 27 /* GreaterThanToken */: case 28 /* LessThanEqualsToken */: case 29 /* GreaterThanEqualsToken */: - case 89 /* InstanceOfKeyword */: - case 88 /* InKeyword */: + case 91 /* InstanceOfKeyword */: + case 90 /* InKeyword */: + case 116 /* AsKeyword */: case 30 /* EqualsEqualsToken */: case 31 /* ExclamationEqualsToken */: case 32 /* EqualsEqualsEqualsToken */: case 33 /* ExclamationEqualsEqualsToken */: - case 45 /* AmpersandToken */: - case 47 /* CaretToken */: - case 46 /* BarToken */: - case 50 /* AmpersandAmpersandToken */: - case 51 /* BarBarToken */: - case 65 /* BarEqualsToken */: - case 64 /* AmpersandEqualsToken */: - case 66 /* CaretEqualsToken */: - case 61 /* LessThanLessThanEqualsToken */: - case 62 /* GreaterThanGreaterThanEqualsToken */: - case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 56 /* PlusEqualsToken */: - case 57 /* MinusEqualsToken */: - case 58 /* AsteriskEqualsToken */: - case 59 /* SlashEqualsToken */: - case 60 /* PercentEqualsToken */: - case 55 /* EqualsToken */: + case 46 /* AmpersandToken */: + case 48 /* CaretToken */: + case 47 /* BarToken */: + case 51 /* AmpersandAmpersandToken */: + case 52 /* BarBarToken */: + case 67 /* BarEqualsToken */: + case 66 /* AmpersandEqualsToken */: + case 68 /* CaretEqualsToken */: + case 63 /* LessThanLessThanEqualsToken */: + case 64 /* GreaterThanGreaterThanEqualsToken */: + case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 57 /* PlusEqualsToken */: + case 58 /* MinusEqualsToken */: + case 59 /* AsteriskEqualsToken */: + case 61 /* SlashEqualsToken */: + case 62 /* PercentEqualsToken */: + case 56 /* EqualsToken */: case 24 /* CommaToken */: return true; default: @@ -48189,17 +49114,17 @@ var ts; switch (token) { case 35 /* PlusToken */: case 36 /* MinusToken */: - case 49 /* TildeToken */: - case 48 /* ExclamationToken */: - case 40 /* PlusPlusToken */: - case 41 /* MinusMinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: + case 41 /* PlusPlusToken */: + case 42 /* MinusMinusToken */: return true; default: return false; } } function isKeyword(token) { - return token >= 68 /* FirstKeyword */ && token <= 132 /* LastKeyword */; + return token >= 70 /* FirstKeyword */ && token <= 134 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -48208,7 +49133,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 15 /* FirstPunctuation */ && token <= 66 /* LastPunctuation */) { + else if (token >= 15 /* FirstPunctuation */ && token <= 68 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -48225,7 +49150,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 67 /* Identifier */: + case 69 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -48257,7 +49182,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 246 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + var proto = kind === 248 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = -1; proto.end = -1; @@ -48327,125 +49252,125 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 195 /* DoStatement */) { + if (node.parent.kind === 197 /* DoStatement */) { // Set span as if on while keyword return spanInPreviousNode(node); } - if (node.parent.kind === 197 /* ForStatement */) { + if (node.parent.kind === 199 /* ForStatement */) { // For now lets set the span on this expression, fix it later return textSpan(node); } - if (node.parent.kind === 179 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) { + if (node.parent.kind === 181 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) { // if this is comma expression, the breakpoint is possible in this expression return textSpan(node); } - if (node.parent.kind === 172 /* ArrowFunction */ && node.parent.body === node) { + if (node.parent.kind === 174 /* ArrowFunction */ && node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); } } switch (node.kind) { - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 209 /* VariableDeclaration */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 211 /* VariableDeclaration */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return spanInVariableDeclaration(node); - case 136 /* Parameter */: + case 138 /* Parameter */: return spanInParameterDeclaration(node); - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 142 /* Constructor */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 190 /* Block */: + case 192 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 217 /* ModuleBlock */: + case 219 /* ModuleBlock */: return spanInBlock(node); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return spanInBlock(node.block); - case 193 /* ExpressionStatement */: + case 195 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 202 /* ReturnStatement */: + case 204 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 196 /* WhileStatement */: + case 198 /* WhileStatement */: // Span on while(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 195 /* DoStatement */: + case 197 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 208 /* DebuggerStatement */: + case 210 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 194 /* IfStatement */: + case 196 /* IfStatement */: // set on if(..) span return textSpan(node, ts.findNextToken(node.expression, node)); - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 201 /* BreakStatement */: - case 200 /* ContinueStatement */: + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 197 /* ForStatement */: + case 199 /* ForStatement */: return spanInForStatement(node); - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: // span on for (a in ...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 204 /* SwitchStatement */: + case 206 /* SwitchStatement */: // span on switch(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 239 /* CaseClause */: - case 240 /* DefaultClause */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 207 /* TryStatement */: + case 209 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 206 /* ThrowStatement */: + case 208 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: - case 245 /* EnumMember */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: // span on complete node return textSpan(node); - case 203 /* WithStatement */: + case 205 /* WithStatement */: // span in statement return spanInNode(node.statement); // No breakpoint in interface, type alias - case 213 /* InterfaceDeclaration */: - case 214 /* TypeAliasDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: return undefined; // Tokens: case 23 /* SemicolonToken */: @@ -48461,25 +49386,25 @@ var ts; return spanInOpenParenToken(node); case 18 /* CloseParenToken */: return spanInCloseParenToken(node); - case 53 /* ColonToken */: + case 54 /* ColonToken */: return spanInColonToken(node); case 27 /* GreaterThanToken */: case 25 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 102 /* WhileKeyword */: + case 104 /* WhileKeyword */: return spanInWhileKeyword(node); - case 78 /* ElseKeyword */: - case 70 /* CatchKeyword */: - case 83 /* FinallyKeyword */: + case 80 /* ElseKeyword */: + case 72 /* CatchKeyword */: + case 85 /* FinallyKeyword */: return spanInNextNode(node); default: // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 243 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 245 /* PropertyAssignment */ && node.parent.name === node) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 169 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 171 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNode(node.parent.expression); } // return type of function go to previous token @@ -48492,12 +49417,12 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 198 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */) { + if (variableDeclaration.parent.parent.kind === 200 /* ForInStatement */ || + variableDeclaration.parent.parent.kind === 201 /* ForOfStatement */) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 191 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 197 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 193 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 199 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -48551,7 +49476,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1 /* Export */) || - (functionDeclaration.parent.kind === 212 /* ClassDeclaration */ && functionDeclaration.kind !== 142 /* Constructor */); + (functionDeclaration.parent.kind === 214 /* ClassDeclaration */ && functionDeclaration.kind !== 144 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -48574,18 +49499,18 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 196 /* WhileStatement */: - case 194 /* IfStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 198 /* WhileStatement */: + case 196 /* IfStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 197 /* ForStatement */: + case 199 /* ForStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement @@ -48593,7 +49518,7 @@ var ts; } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 210 /* VariableDeclarationList */) { + if (forStatement.initializer.kind === 212 /* VariableDeclarationList */) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -48613,13 +49538,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 218 /* CaseBlock */: + case 220 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -48627,25 +49552,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 217 /* ModuleBlock */: + case 219 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 215 /* EnumDeclaration */: - case 212 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 214 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 190 /* Block */: + case 192 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 242 /* CatchClause */: + case 244 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 218 /* CaseBlock */: + case 220 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -48659,7 +49584,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 195 /* DoStatement */) { + if (node.parent.kind === 197 /* DoStatement */) { // Go to while keyword and do action instead return spanInPreviousNode(node); } @@ -48669,17 +49594,17 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 171 /* FunctionExpression */: - case 211 /* FunctionDeclaration */: - case 172 /* ArrowFunction */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 142 /* Constructor */: - case 196 /* WhileStatement */: - case 195 /* DoStatement */: - case 197 /* ForStatement */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: + case 198 /* WhileStatement */: + case 197 /* DoStatement */: + case 199 /* ForStatement */: return spanInPreviousNode(node); // Default to parent node default: @@ -48690,19 +49615,19 @@ var ts; } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 243 /* PropertyAssignment */) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 245 /* PropertyAssignment */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 169 /* TypeAssertionExpression */) { + if (node.parent.kind === 171 /* TypeAssertionExpression */) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 195 /* DoStatement */) { + if (node.parent.kind === 197 /* DoStatement */) { // Set span on while expression return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } @@ -49339,7 +50264,8 @@ var ts; }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { - var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); + // for now treat files as JavaScript + var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), /* readImportFiles */ true, /* detectJavaScriptImports */ true); var convertResult = { referencedFiles: [], importedFiles: [], diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 761ce39d4185f..8e6c6a553a5bf 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -68,253 +68,255 @@ declare namespace ts { PlusToken = 35, MinusToken = 36, AsteriskToken = 37, - SlashToken = 38, - PercentToken = 39, - PlusPlusToken = 40, - MinusMinusToken = 41, - LessThanLessThanToken = 42, - GreaterThanGreaterThanToken = 43, - GreaterThanGreaterThanGreaterThanToken = 44, - AmpersandToken = 45, - BarToken = 46, - CaretToken = 47, - ExclamationToken = 48, - TildeToken = 49, - AmpersandAmpersandToken = 50, - BarBarToken = 51, - QuestionToken = 52, - ColonToken = 53, - AtToken = 54, - EqualsToken = 55, - PlusEqualsToken = 56, - MinusEqualsToken = 57, - AsteriskEqualsToken = 58, - SlashEqualsToken = 59, - PercentEqualsToken = 60, - LessThanLessThanEqualsToken = 61, - GreaterThanGreaterThanEqualsToken = 62, - GreaterThanGreaterThanGreaterThanEqualsToken = 63, - AmpersandEqualsToken = 64, - BarEqualsToken = 65, - CaretEqualsToken = 66, - Identifier = 67, - BreakKeyword = 68, - CaseKeyword = 69, - CatchKeyword = 70, - ClassKeyword = 71, - ConstKeyword = 72, - ContinueKeyword = 73, - DebuggerKeyword = 74, - DefaultKeyword = 75, - DeleteKeyword = 76, - DoKeyword = 77, - ElseKeyword = 78, - EnumKeyword = 79, - ExportKeyword = 80, - ExtendsKeyword = 81, - FalseKeyword = 82, - FinallyKeyword = 83, - ForKeyword = 84, - FunctionKeyword = 85, - IfKeyword = 86, - ImportKeyword = 87, - InKeyword = 88, - InstanceOfKeyword = 89, - NewKeyword = 90, - NullKeyword = 91, - ReturnKeyword = 92, - SuperKeyword = 93, - SwitchKeyword = 94, - ThisKeyword = 95, - ThrowKeyword = 96, - TrueKeyword = 97, - TryKeyword = 98, - TypeOfKeyword = 99, - VarKeyword = 100, - VoidKeyword = 101, - WhileKeyword = 102, - WithKeyword = 103, - ImplementsKeyword = 104, - InterfaceKeyword = 105, - LetKeyword = 106, - PackageKeyword = 107, - PrivateKeyword = 108, - ProtectedKeyword = 109, - PublicKeyword = 110, - StaticKeyword = 111, - YieldKeyword = 112, - AbstractKeyword = 113, - AsKeyword = 114, - AnyKeyword = 115, - AsyncKeyword = 116, - AwaitKeyword = 117, - BooleanKeyword = 118, - ConstructorKeyword = 119, - DeclareKeyword = 120, - GetKeyword = 121, - IsKeyword = 122, - ModuleKeyword = 123, - NamespaceKeyword = 124, - RequireKeyword = 125, - NumberKeyword = 126, - SetKeyword = 127, - StringKeyword = 128, - SymbolKeyword = 129, - TypeKeyword = 130, - FromKeyword = 131, - OfKeyword = 132, - QualifiedName = 133, - ComputedPropertyName = 134, - TypeParameter = 135, - Parameter = 136, - Decorator = 137, - PropertySignature = 138, - PropertyDeclaration = 139, - MethodSignature = 140, - MethodDeclaration = 141, - Constructor = 142, - GetAccessor = 143, - SetAccessor = 144, - CallSignature = 145, - ConstructSignature = 146, - IndexSignature = 147, - TypePredicate = 148, - TypeReference = 149, - FunctionType = 150, - ConstructorType = 151, - TypeQuery = 152, - TypeLiteral = 153, - ArrayType = 154, - TupleType = 155, - UnionType = 156, - IntersectionType = 157, - ParenthesizedType = 158, - ObjectBindingPattern = 159, - ArrayBindingPattern = 160, - BindingElement = 161, - ArrayLiteralExpression = 162, - ObjectLiteralExpression = 163, - PropertyAccessExpression = 164, - ElementAccessExpression = 165, - CallExpression = 166, - NewExpression = 167, - TaggedTemplateExpression = 168, - TypeAssertionExpression = 169, - ParenthesizedExpression = 170, - FunctionExpression = 171, - ArrowFunction = 172, - DeleteExpression = 173, - TypeOfExpression = 174, - VoidExpression = 175, - AwaitExpression = 176, - PrefixUnaryExpression = 177, - PostfixUnaryExpression = 178, - BinaryExpression = 179, - ConditionalExpression = 180, - TemplateExpression = 181, - YieldExpression = 182, - SpreadElementExpression = 183, - ClassExpression = 184, - OmittedExpression = 185, - ExpressionWithTypeArguments = 186, - AsExpression = 187, - TemplateSpan = 188, - SemicolonClassElement = 189, - Block = 190, - VariableStatement = 191, - EmptyStatement = 192, - ExpressionStatement = 193, - IfStatement = 194, - DoStatement = 195, - WhileStatement = 196, - ForStatement = 197, - ForInStatement = 198, - ForOfStatement = 199, - ContinueStatement = 200, - BreakStatement = 201, - ReturnStatement = 202, - WithStatement = 203, - SwitchStatement = 204, - LabeledStatement = 205, - ThrowStatement = 206, - TryStatement = 207, - DebuggerStatement = 208, - VariableDeclaration = 209, - VariableDeclarationList = 210, - FunctionDeclaration = 211, - ClassDeclaration = 212, - InterfaceDeclaration = 213, - TypeAliasDeclaration = 214, - EnumDeclaration = 215, - ModuleDeclaration = 216, - ModuleBlock = 217, - CaseBlock = 218, - ImportEqualsDeclaration = 219, - ImportDeclaration = 220, - ImportClause = 221, - NamespaceImport = 222, - NamedImports = 223, - ImportSpecifier = 224, - ExportAssignment = 225, - ExportDeclaration = 226, - NamedExports = 227, - ExportSpecifier = 228, - MissingDeclaration = 229, - ExternalModuleReference = 230, - JsxElement = 231, - JsxSelfClosingElement = 232, - JsxOpeningElement = 233, - JsxText = 234, - JsxClosingElement = 235, - JsxAttribute = 236, - JsxSpreadAttribute = 237, - JsxExpression = 238, - CaseClause = 239, - DefaultClause = 240, - HeritageClause = 241, - CatchClause = 242, - PropertyAssignment = 243, - ShorthandPropertyAssignment = 244, - EnumMember = 245, - SourceFile = 246, - JSDocTypeExpression = 247, - JSDocAllType = 248, - JSDocUnknownType = 249, - JSDocArrayType = 250, - JSDocUnionType = 251, - JSDocTupleType = 252, - JSDocNullableType = 253, - JSDocNonNullableType = 254, - JSDocRecordType = 255, - JSDocRecordMember = 256, - JSDocTypeReference = 257, - JSDocOptionalType = 258, - JSDocFunctionType = 259, - JSDocVariadicType = 260, - JSDocConstructorType = 261, - JSDocThisType = 262, - JSDocComment = 263, - JSDocTag = 264, - JSDocParameterTag = 265, - JSDocReturnTag = 266, - JSDocTypeTag = 267, - JSDocTemplateTag = 268, - SyntaxList = 269, - Count = 270, - FirstAssignment = 55, - LastAssignment = 66, - FirstReservedWord = 68, - LastReservedWord = 103, - FirstKeyword = 68, - LastKeyword = 132, - FirstFutureReservedWord = 104, - LastFutureReservedWord = 112, - FirstTypeNode = 149, - LastTypeNode = 158, + AsteriskAsteriskToken = 38, + SlashToken = 39, + PercentToken = 40, + PlusPlusToken = 41, + MinusMinusToken = 42, + LessThanLessThanToken = 43, + GreaterThanGreaterThanToken = 44, + GreaterThanGreaterThanGreaterThanToken = 45, + AmpersandToken = 46, + BarToken = 47, + CaretToken = 48, + ExclamationToken = 49, + TildeToken = 50, + AmpersandAmpersandToken = 51, + BarBarToken = 52, + QuestionToken = 53, + ColonToken = 54, + AtToken = 55, + EqualsToken = 56, + PlusEqualsToken = 57, + MinusEqualsToken = 58, + AsteriskEqualsToken = 59, + AsteriskAsteriskEqualsToken = 60, + SlashEqualsToken = 61, + PercentEqualsToken = 62, + LessThanLessThanEqualsToken = 63, + GreaterThanGreaterThanEqualsToken = 64, + GreaterThanGreaterThanGreaterThanEqualsToken = 65, + AmpersandEqualsToken = 66, + BarEqualsToken = 67, + CaretEqualsToken = 68, + Identifier = 69, + BreakKeyword = 70, + CaseKeyword = 71, + CatchKeyword = 72, + ClassKeyword = 73, + ConstKeyword = 74, + ContinueKeyword = 75, + DebuggerKeyword = 76, + DefaultKeyword = 77, + DeleteKeyword = 78, + DoKeyword = 79, + ElseKeyword = 80, + EnumKeyword = 81, + ExportKeyword = 82, + ExtendsKeyword = 83, + FalseKeyword = 84, + FinallyKeyword = 85, + ForKeyword = 86, + FunctionKeyword = 87, + IfKeyword = 88, + ImportKeyword = 89, + InKeyword = 90, + InstanceOfKeyword = 91, + NewKeyword = 92, + NullKeyword = 93, + ReturnKeyword = 94, + SuperKeyword = 95, + SwitchKeyword = 96, + ThisKeyword = 97, + ThrowKeyword = 98, + TrueKeyword = 99, + TryKeyword = 100, + TypeOfKeyword = 101, + VarKeyword = 102, + VoidKeyword = 103, + WhileKeyword = 104, + WithKeyword = 105, + ImplementsKeyword = 106, + InterfaceKeyword = 107, + LetKeyword = 108, + PackageKeyword = 109, + PrivateKeyword = 110, + ProtectedKeyword = 111, + PublicKeyword = 112, + StaticKeyword = 113, + YieldKeyword = 114, + AbstractKeyword = 115, + AsKeyword = 116, + AnyKeyword = 117, + AsyncKeyword = 118, + AwaitKeyword = 119, + BooleanKeyword = 120, + ConstructorKeyword = 121, + DeclareKeyword = 122, + GetKeyword = 123, + IsKeyword = 124, + ModuleKeyword = 125, + NamespaceKeyword = 126, + RequireKeyword = 127, + NumberKeyword = 128, + SetKeyword = 129, + StringKeyword = 130, + SymbolKeyword = 131, + TypeKeyword = 132, + FromKeyword = 133, + OfKeyword = 134, + QualifiedName = 135, + ComputedPropertyName = 136, + TypeParameter = 137, + Parameter = 138, + Decorator = 139, + PropertySignature = 140, + PropertyDeclaration = 141, + MethodSignature = 142, + MethodDeclaration = 143, + Constructor = 144, + GetAccessor = 145, + SetAccessor = 146, + CallSignature = 147, + ConstructSignature = 148, + IndexSignature = 149, + TypePredicate = 150, + TypeReference = 151, + FunctionType = 152, + ConstructorType = 153, + TypeQuery = 154, + TypeLiteral = 155, + ArrayType = 156, + TupleType = 157, + UnionType = 158, + IntersectionType = 159, + ParenthesizedType = 160, + ObjectBindingPattern = 161, + ArrayBindingPattern = 162, + BindingElement = 163, + ArrayLiteralExpression = 164, + ObjectLiteralExpression = 165, + PropertyAccessExpression = 166, + ElementAccessExpression = 167, + CallExpression = 168, + NewExpression = 169, + TaggedTemplateExpression = 170, + TypeAssertionExpression = 171, + ParenthesizedExpression = 172, + FunctionExpression = 173, + ArrowFunction = 174, + DeleteExpression = 175, + TypeOfExpression = 176, + VoidExpression = 177, + AwaitExpression = 178, + PrefixUnaryExpression = 179, + PostfixUnaryExpression = 180, + BinaryExpression = 181, + ConditionalExpression = 182, + TemplateExpression = 183, + YieldExpression = 184, + SpreadElementExpression = 185, + ClassExpression = 186, + OmittedExpression = 187, + ExpressionWithTypeArguments = 188, + AsExpression = 189, + TemplateSpan = 190, + SemicolonClassElement = 191, + Block = 192, + VariableStatement = 193, + EmptyStatement = 194, + ExpressionStatement = 195, + IfStatement = 196, + DoStatement = 197, + WhileStatement = 198, + ForStatement = 199, + ForInStatement = 200, + ForOfStatement = 201, + ContinueStatement = 202, + BreakStatement = 203, + ReturnStatement = 204, + WithStatement = 205, + SwitchStatement = 206, + LabeledStatement = 207, + ThrowStatement = 208, + TryStatement = 209, + DebuggerStatement = 210, + VariableDeclaration = 211, + VariableDeclarationList = 212, + FunctionDeclaration = 213, + ClassDeclaration = 214, + InterfaceDeclaration = 215, + TypeAliasDeclaration = 216, + EnumDeclaration = 217, + ModuleDeclaration = 218, + ModuleBlock = 219, + CaseBlock = 220, + ImportEqualsDeclaration = 221, + ImportDeclaration = 222, + ImportClause = 223, + NamespaceImport = 224, + NamedImports = 225, + ImportSpecifier = 226, + ExportAssignment = 227, + ExportDeclaration = 228, + NamedExports = 229, + ExportSpecifier = 230, + MissingDeclaration = 231, + ExternalModuleReference = 232, + JsxElement = 233, + JsxSelfClosingElement = 234, + JsxOpeningElement = 235, + JsxText = 236, + JsxClosingElement = 237, + JsxAttribute = 238, + JsxSpreadAttribute = 239, + JsxExpression = 240, + CaseClause = 241, + DefaultClause = 242, + HeritageClause = 243, + CatchClause = 244, + PropertyAssignment = 245, + ShorthandPropertyAssignment = 246, + EnumMember = 247, + SourceFile = 248, + JSDocTypeExpression = 249, + JSDocAllType = 250, + JSDocUnknownType = 251, + JSDocArrayType = 252, + JSDocUnionType = 253, + JSDocTupleType = 254, + JSDocNullableType = 255, + JSDocNonNullableType = 256, + JSDocRecordType = 257, + JSDocRecordMember = 258, + JSDocTypeReference = 259, + JSDocOptionalType = 260, + JSDocFunctionType = 261, + JSDocVariadicType = 262, + JSDocConstructorType = 263, + JSDocThisType = 264, + JSDocComment = 265, + JSDocTag = 266, + JSDocParameterTag = 267, + JSDocReturnTag = 268, + JSDocTypeTag = 269, + JSDocTemplateTag = 270, + SyntaxList = 271, + Count = 272, + FirstAssignment = 56, + LastAssignment = 68, + FirstReservedWord = 70, + LastReservedWord = 105, + FirstKeyword = 70, + LastKeyword = 134, + FirstFutureReservedWord = 106, + LastFutureReservedWord = 114, + FirstTypeNode = 151, + LastTypeNode = 160, FirstPunctuation = 15, - LastPunctuation = 66, + LastPunctuation = 68, FirstToken = 0, - LastToken = 132, + LastToken = 134, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -322,8 +324,8 @@ declare namespace ts { FirstTemplateToken = 11, LastTemplateToken = 14, FirstBinaryOperator = 25, - LastBinaryOperator = 66, - FirstNode = 133, + LastBinaryOperator = 68, + FirstNode = 135, } const enum NodeFlags { Export = 1, @@ -343,6 +345,7 @@ declare namespace ts { OctalLiteral = 65536, Namespace = 131072, ExportContext = 262144, + ContainsThis = 524288, Modifier = 2035, AccessibilityModifier = 112, BlockScoped = 49152, @@ -438,6 +441,8 @@ declare namespace ts { interface ShorthandPropertyAssignment extends ObjectLiteralElement { name: Identifier; questionToken?: Node; + equalsToken?: Node; + objectAssignmentInitializer?: Expression; } interface VariableLikeDeclaration extends Declaration { propertyName?: Identifier; @@ -530,18 +535,21 @@ declare namespace ts { interface UnaryExpression extends Expression { _unaryExpressionBrand: any; } - interface PrefixUnaryExpression extends UnaryExpression { + interface IncrementExpression extends UnaryExpression { + _incrementExpressionBrand: any; + } + interface PrefixUnaryExpression extends IncrementExpression { operator: SyntaxKind; operand: UnaryExpression; } - interface PostfixUnaryExpression extends PostfixExpression { + interface PostfixUnaryExpression extends IncrementExpression { operand: LeftHandSideExpression; operator: SyntaxKind; } interface PostfixExpression extends UnaryExpression { _postfixExpressionBrand: any; } - interface LeftHandSideExpression extends PostfixExpression { + interface LeftHandSideExpression extends IncrementExpression { _leftHandSideExpressionBrand: any; } interface MemberExpression extends LeftHandSideExpression { @@ -566,7 +574,7 @@ declare namespace ts { asteriskToken?: Node; expression?: Expression; } - interface BinaryExpression extends Expression { + interface BinaryExpression extends Expression, Declaration { left: Expression; operatorToken: Node; right: Expression; @@ -610,7 +618,7 @@ declare namespace ts { interface ObjectLiteralExpression extends PrimaryExpression, Declaration { properties: NodeArray; } - interface PropertyAccessExpression extends MemberExpression { + interface PropertyAccessExpression extends MemberExpression, Declaration { expression: LeftHandSideExpression; dotToken: Node; name: Identifier; @@ -1082,6 +1090,7 @@ declare namespace ts { decreaseIndent(): void; clear(): void; trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; + reportInaccessibleThisError(): void; } const enum TypeFormatFlags { None = 0, @@ -1202,6 +1211,7 @@ declare namespace ts { Instantiated = 131072, ObjectLiteral = 524288, ESSymbol = 16777216, + ThisType = 33554432, StringLike = 258, NumberLike = 132, ObjectType = 80896, @@ -1223,6 +1233,7 @@ declare namespace ts { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; + thisType: TypeParameter; } interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; @@ -1337,7 +1348,6 @@ declare namespace ts { watch?: boolean; isolatedModules?: boolean; experimentalDecorators?: boolean; - experimentalAsyncFunctions?: boolean; emitDecoratorMetadata?: boolean; moduleResolution?: ModuleResolutionKind; [option: string]: string | number | boolean; @@ -1348,6 +1358,7 @@ declare namespace ts { AMD = 2, UMD = 3, System = 4, + ES6 = 5, } const enum JsxEmit { None = 0, @@ -1417,7 +1428,7 @@ declare namespace ts { write(s: string): void; readFile(path: string, encoding?: string): string; writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; - watchFile?(path: string, callback: (path: string) => void): FileWatcher; + watchFile?(path: string, callback: (path: string, removed: boolean) => void): FileWatcher; resolvePath(path: string): string; fileExists(path: string): boolean; directoryExists(path: string): boolean; @@ -1775,6 +1786,12 @@ declare namespace ts { TabSize: number; NewLineCharacter: string; ConvertTabsToSpaces: boolean; + IndentStyle: IndentStyle; + } + enum IndentStyle { + None = 0, + Block = 1, + Smart = 2, } interface FormatCodeOptions extends EditorOptions { InsertSpaceAfterCommaDelimiter: boolean; @@ -2132,7 +2149,7 @@ declare namespace ts { function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string; function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; - function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; + function preProcessFile(sourceText: string, readImportFiles?: boolean, detectJavaScriptImports?: boolean): PreProcessedFileInfo; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; function createClassifier(): Classifier; /** diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index a1f9651570e18..d261ce125fc65 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -62,279 +62,281 @@ var ts; SyntaxKind[SyntaxKind["PlusToken"] = 35] = "PlusToken"; SyntaxKind[SyntaxKind["MinusToken"] = 36] = "MinusToken"; SyntaxKind[SyntaxKind["AsteriskToken"] = 37] = "AsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 38] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 39] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 40] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 41] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 42] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 43] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 44] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 45] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 46] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 47] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 48] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 49] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 50] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 51] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 52] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 53] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 54] = "AtToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 38] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 39] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 40] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 41] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 42] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 43] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 44] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 46] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 47] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 48] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 49] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 50] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 51] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 52] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 53] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 54] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 55] = "AtToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 55] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 56] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 57] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 58] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 59] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 60] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 61] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 62] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 63] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 64] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 65] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 66] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 56] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 57] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 58] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 59] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 60] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 61] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 62] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 63] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 64] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 66] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 67] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 68] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 67] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 69] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 68] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 69] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 70] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 71] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 72] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 73] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 74] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 75] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 76] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 77] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 78] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 79] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 80] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 81] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 82] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 83] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 84] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 85] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 86] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 87] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 88] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 89] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 90] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 91] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 92] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 93] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 94] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 95] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 96] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 97] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 98] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 99] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 100] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 101] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 102] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 103] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 70] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 71] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 72] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 73] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 74] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 75] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 76] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 77] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 78] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 79] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 80] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 81] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 82] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 83] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 84] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 85] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 86] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 87] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 88] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 89] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 90] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 91] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 92] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 93] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 94] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 95] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 96] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 97] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 98] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 99] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 100] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 101] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 102] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 103] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 104] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 105] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 104] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 105] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 106] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 107] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 108] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 109] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 110] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 111] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 112] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 106] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 107] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 108] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 109] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 110] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 111] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 112] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 113] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 114] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 113] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 114] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 115] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 116] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 117] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 118] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 119] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 120] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 121] = "GetKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 122] = "IsKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 123] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 124] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 125] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 126] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 127] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 128] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 129] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 130] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 131] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 132] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 115] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 116] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 117] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 118] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 119] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 120] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 121] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 122] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 123] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 124] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 125] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 126] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 127] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 128] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 129] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 130] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 131] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 132] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 133] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 134] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 133] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 134] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 135] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 136] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 135] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 136] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 137] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 137] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 138] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 139] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 138] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 139] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 140] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 141] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 142] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 143] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 144] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 145] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 146] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 147] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 140] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 141] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 142] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 143] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 144] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 145] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 146] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 147] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 148] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 149] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 148] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 149] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 150] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 151] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 152] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 153] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 154] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 155] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 156] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 157] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 158] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 150] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 151] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 152] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 153] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 154] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 155] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 156] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 157] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 158] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 159] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 160] = "ParenthesizedType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 159] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 160] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 161] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 161] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 162] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 163] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 162] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 163] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 164] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 165] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 166] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 167] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 168] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 169] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 170] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 171] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 172] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 173] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 174] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 175] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 176] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 177] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 178] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 179] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 180] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 181] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 182] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 183] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 184] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 185] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 186] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 187] = "AsExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 164] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 165] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 166] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 167] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 168] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 169] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 170] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 171] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 172] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 173] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 174] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 175] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 176] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 177] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 178] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 179] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 180] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 181] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 182] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 183] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 184] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 185] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 186] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 187] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 188] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 189] = "AsExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 188] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 189] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 190] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 191] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 190] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 191] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 192] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 193] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 194] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 195] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 196] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 197] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 198] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 199] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 200] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 201] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 202] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 203] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 204] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 205] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 206] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 207] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 208] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 209] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 210] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 211] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 212] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 213] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 214] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 215] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 216] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 217] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 218] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 219] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 220] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 221] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 222] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 223] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 224] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 225] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 226] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 227] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 228] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 229] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 192] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 193] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 194] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 195] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 196] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 197] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 198] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 199] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 200] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 201] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 202] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 203] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 204] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 205] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 206] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 207] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 208] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 209] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 210] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 211] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 212] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 213] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 214] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 215] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 216] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 217] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 218] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 219] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 220] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 221] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 222] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 223] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 224] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 225] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 226] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 227] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 228] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 229] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 230] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 231] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 230] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 232] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 231] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 232] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 233] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxText"] = 234] = "JsxText"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 235] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 236] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 237] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 238] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 233] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 234] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 235] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxText"] = 236] = "JsxText"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 237] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 238] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 239] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 240] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 239] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 240] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 241] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 242] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 241] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 242] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 243] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 244] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 243] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 244] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 245] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 246] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 245] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 247] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 246] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 248] = "SourceFile"; // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 247] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 249] = "JSDocTypeExpression"; // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 248] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 250] = "JSDocAllType"; // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 249] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 250] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 251] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 252] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 253] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 254] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 255] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 256] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 257] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 258] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 259] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 260] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 261] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 262] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 263] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 264] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 265] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 266] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 267] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 268] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 251] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 252] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 253] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 254] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 255] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 256] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 257] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 258] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 259] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 260] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 261] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 262] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 263] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 264] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 265] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 266] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 267] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 268] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 269] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 270] = "JSDocTemplateTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 269] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 271] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 270] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 272] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 55] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 66] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 68] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 103] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 68] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 132] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 104] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 112] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 149] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 158] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 56] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 68] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 70] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 105] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 70] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 134] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 106] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 114] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 151] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 160] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 66] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 68] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 132] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 134] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -342,8 +344,8 @@ var ts; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 11] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 14] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 25] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 66] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 133] = "FirstNode"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 68] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 135] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -364,6 +366,7 @@ var ts; NodeFlags[NodeFlags["OctalLiteral"] = 65536] = "OctalLiteral"; NodeFlags[NodeFlags["Namespace"] = 131072] = "Namespace"; NodeFlags[NodeFlags["ExportContext"] = 262144] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 524288] = "ContainsThis"; NodeFlags[NodeFlags["Modifier"] = 2035] = "Modifier"; NodeFlags[NodeFlags["AccessibilityModifier"] = 112] = "AccessibilityModifier"; NodeFlags[NodeFlags["BlockScoped"] = 49152] = "BlockScoped"; @@ -613,6 +616,7 @@ var ts; /* @internal */ TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; TypeFlags[TypeFlags["ESSymbol"] = 16777216] = "ESSymbol"; + TypeFlags[TypeFlags["ThisType"] = 33554432] = "ThisType"; /* @internal */ TypeFlags[TypeFlags["Intrinsic"] = 16777343] = "Intrinsic"; /* @internal */ @@ -655,6 +659,7 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; + ModuleKind[ModuleKind["ES6"] = 5] = "ES6"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; (function (JsxEmit) { @@ -1221,8 +1226,11 @@ var ts; } ts.chainDiagnosticMessages = chainDiagnosticMessages; function concatenateDiagnosticMessageChains(headChain, tailChain) { - Debug.assert(!headChain.next); - headChain.next = tailChain; + var lastChain = headChain; + while (lastChain.next) { + lastChain = lastChain.next; + } + lastChain.next = tailChain; return headChain; } ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; @@ -1496,6 +1504,7 @@ var ts; * List of supported extensions in order of file resolution precedence. */ ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; + ts.supportedJsExtensions = ts.supportedExtensions.concat(".js", ".jsx"); var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { @@ -1819,10 +1828,15 @@ var ts; close: function () { _fs.unwatchFile(fileName, fileChanged); } }; function fileChanged(curr, prev) { + // mtime.getTime() equals 0 if file was removed + if (curr.mtime.getTime() === 0) { + callback(fileName, /* removed */ true); + return; + } if (+curr.mtime <= +prev.mtime) { return; } - callback(fileName); + callback(fileName, /* removed */ false); } }, resolvePath: function (path) { @@ -1925,7 +1939,7 @@ var ts; Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum member must have initializer." }, _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, - 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." }, + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In ambient enum declarations member initializer must be constant expression." }, 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_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, @@ -2013,7 +2027,7 @@ var ts; 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." }, - An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, + An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1183, 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." }, @@ -2031,10 +2045,9 @@ var ts; 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." }, - 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_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' 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." }, + Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." }, + Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." }, + Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es6' when targeting 'ES5' or lower." }, 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." }, Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, @@ -2063,10 +2076,6 @@ var ts; An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, - Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning: { code: 1236, category: ts.DiagnosticCategory.Error, key: "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning." }, - with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, - await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, - Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, @@ -2077,6 +2086,10 @@ var ts; _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." }, Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." }, Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method '{0}' cannot have an implementation because it is marked abstract." }, + with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, + await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, + Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, + can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "'=' can only be used in an object literal property inside a destructuring assignment." }, 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." }, @@ -2201,7 +2214,7 @@ var ts; 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_namespace_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 namespace declaration cannot be in a different file from a class or function with which it is merged" }, A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules." }, + Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules or namespaces." }, Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient 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}'" }, @@ -2289,6 +2302,9 @@ var ts; yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." }, + A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A 'this' type is available only in a non-static member of a class or interface." }, + The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, + A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A module cannot have multiple default exports." }, JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2389,7 +2405,7 @@ var ts; Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, - A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, 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." }, @@ -2401,7 +2417,7 @@ var ts; 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_amd_system_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'" }, + Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es6'" }, 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." }, @@ -2422,7 +2438,7 @@ var ts; 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_amd_system_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'." }, + Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es6'." }, 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}'." }, @@ -2443,7 +2459,6 @@ var ts; Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, - Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, @@ -2490,7 +2505,9 @@ var ts; Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" }, + An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, + A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." } }; })(ts || (ts = {})); /// @@ -2499,75 +2516,75 @@ var ts; (function (ts) { /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 67 /* Identifier */; + return token >= 69 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = { - "abstract": 113 /* AbstractKeyword */, - "any": 115 /* AnyKeyword */, - "as": 114 /* AsKeyword */, - "boolean": 118 /* BooleanKeyword */, - "break": 68 /* BreakKeyword */, - "case": 69 /* CaseKeyword */, - "catch": 70 /* CatchKeyword */, - "class": 71 /* ClassKeyword */, - "continue": 73 /* ContinueKeyword */, - "const": 72 /* ConstKeyword */, - "constructor": 119 /* ConstructorKeyword */, - "debugger": 74 /* DebuggerKeyword */, - "declare": 120 /* DeclareKeyword */, - "default": 75 /* DefaultKeyword */, - "delete": 76 /* DeleteKeyword */, - "do": 77 /* DoKeyword */, - "else": 78 /* ElseKeyword */, - "enum": 79 /* EnumKeyword */, - "export": 80 /* ExportKeyword */, - "extends": 81 /* ExtendsKeyword */, - "false": 82 /* FalseKeyword */, - "finally": 83 /* FinallyKeyword */, - "for": 84 /* ForKeyword */, - "from": 131 /* FromKeyword */, - "function": 85 /* FunctionKeyword */, - "get": 121 /* GetKeyword */, - "if": 86 /* IfKeyword */, - "implements": 104 /* ImplementsKeyword */, - "import": 87 /* ImportKeyword */, - "in": 88 /* InKeyword */, - "instanceof": 89 /* InstanceOfKeyword */, - "interface": 105 /* InterfaceKeyword */, - "is": 122 /* IsKeyword */, - "let": 106 /* LetKeyword */, - "module": 123 /* ModuleKeyword */, - "namespace": 124 /* NamespaceKeyword */, - "new": 90 /* NewKeyword */, - "null": 91 /* NullKeyword */, - "number": 126 /* NumberKeyword */, - "package": 107 /* PackageKeyword */, - "private": 108 /* PrivateKeyword */, - "protected": 109 /* ProtectedKeyword */, - "public": 110 /* PublicKeyword */, - "require": 125 /* RequireKeyword */, - "return": 92 /* ReturnKeyword */, - "set": 127 /* SetKeyword */, - "static": 111 /* StaticKeyword */, - "string": 128 /* StringKeyword */, - "super": 93 /* SuperKeyword */, - "switch": 94 /* SwitchKeyword */, - "symbol": 129 /* SymbolKeyword */, - "this": 95 /* ThisKeyword */, - "throw": 96 /* ThrowKeyword */, - "true": 97 /* TrueKeyword */, - "try": 98 /* TryKeyword */, - "type": 130 /* TypeKeyword */, - "typeof": 99 /* TypeOfKeyword */, - "var": 100 /* VarKeyword */, - "void": 101 /* VoidKeyword */, - "while": 102 /* WhileKeyword */, - "with": 103 /* WithKeyword */, - "yield": 112 /* YieldKeyword */, - "async": 116 /* AsyncKeyword */, - "await": 117 /* AwaitKeyword */, - "of": 132 /* OfKeyword */, + "abstract": 115 /* AbstractKeyword */, + "any": 117 /* AnyKeyword */, + "as": 116 /* AsKeyword */, + "boolean": 120 /* BooleanKeyword */, + "break": 70 /* BreakKeyword */, + "case": 71 /* CaseKeyword */, + "catch": 72 /* CatchKeyword */, + "class": 73 /* ClassKeyword */, + "continue": 75 /* ContinueKeyword */, + "const": 74 /* ConstKeyword */, + "constructor": 121 /* ConstructorKeyword */, + "debugger": 76 /* DebuggerKeyword */, + "declare": 122 /* DeclareKeyword */, + "default": 77 /* DefaultKeyword */, + "delete": 78 /* DeleteKeyword */, + "do": 79 /* DoKeyword */, + "else": 80 /* ElseKeyword */, + "enum": 81 /* EnumKeyword */, + "export": 82 /* ExportKeyword */, + "extends": 83 /* ExtendsKeyword */, + "false": 84 /* FalseKeyword */, + "finally": 85 /* FinallyKeyword */, + "for": 86 /* ForKeyword */, + "from": 133 /* FromKeyword */, + "function": 87 /* FunctionKeyword */, + "get": 123 /* GetKeyword */, + "if": 88 /* IfKeyword */, + "implements": 106 /* ImplementsKeyword */, + "import": 89 /* ImportKeyword */, + "in": 90 /* InKeyword */, + "instanceof": 91 /* InstanceOfKeyword */, + "interface": 107 /* InterfaceKeyword */, + "is": 124 /* IsKeyword */, + "let": 108 /* LetKeyword */, + "module": 125 /* ModuleKeyword */, + "namespace": 126 /* NamespaceKeyword */, + "new": 92 /* NewKeyword */, + "null": 93 /* NullKeyword */, + "number": 128 /* NumberKeyword */, + "package": 109 /* PackageKeyword */, + "private": 110 /* PrivateKeyword */, + "protected": 111 /* ProtectedKeyword */, + "public": 112 /* PublicKeyword */, + "require": 127 /* RequireKeyword */, + "return": 94 /* ReturnKeyword */, + "set": 129 /* SetKeyword */, + "static": 113 /* StaticKeyword */, + "string": 130 /* StringKeyword */, + "super": 95 /* SuperKeyword */, + "switch": 96 /* SwitchKeyword */, + "symbol": 131 /* SymbolKeyword */, + "this": 97 /* ThisKeyword */, + "throw": 98 /* ThrowKeyword */, + "true": 99 /* TrueKeyword */, + "try": 100 /* TryKeyword */, + "type": 132 /* TypeKeyword */, + "typeof": 101 /* TypeOfKeyword */, + "var": 102 /* VarKeyword */, + "void": 103 /* VoidKeyword */, + "while": 104 /* WhileKeyword */, + "with": 105 /* WithKeyword */, + "yield": 114 /* YieldKeyword */, + "async": 118 /* AsyncKeyword */, + "await": 119 /* AwaitKeyword */, + "of": 134 /* OfKeyword */, "{": 15 /* OpenBraceToken */, "}": 16 /* CloseBraceToken */, "(": 17 /* OpenParenToken */, @@ -2589,37 +2606,39 @@ var ts; "=>": 34 /* EqualsGreaterThanToken */, "+": 35 /* PlusToken */, "-": 36 /* MinusToken */, + "**": 38 /* AsteriskAsteriskToken */, "*": 37 /* AsteriskToken */, - "/": 38 /* SlashToken */, - "%": 39 /* PercentToken */, - "++": 40 /* PlusPlusToken */, - "--": 41 /* MinusMinusToken */, - "<<": 42 /* LessThanLessThanToken */, + "/": 39 /* SlashToken */, + "%": 40 /* PercentToken */, + "++": 41 /* PlusPlusToken */, + "--": 42 /* MinusMinusToken */, + "<<": 43 /* LessThanLessThanToken */, ">": 43 /* GreaterThanGreaterThanToken */, - ">>>": 44 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 45 /* AmpersandToken */, - "|": 46 /* BarToken */, - "^": 47 /* CaretToken */, - "!": 48 /* ExclamationToken */, - "~": 49 /* TildeToken */, - "&&": 50 /* AmpersandAmpersandToken */, - "||": 51 /* BarBarToken */, - "?": 52 /* QuestionToken */, - ":": 53 /* ColonToken */, - "=": 55 /* EqualsToken */, - "+=": 56 /* PlusEqualsToken */, - "-=": 57 /* MinusEqualsToken */, - "*=": 58 /* AsteriskEqualsToken */, - "/=": 59 /* SlashEqualsToken */, - "%=": 60 /* PercentEqualsToken */, - "<<=": 61 /* LessThanLessThanEqualsToken */, - ">>=": 62 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 64 /* AmpersandEqualsToken */, - "|=": 65 /* BarEqualsToken */, - "^=": 66 /* CaretEqualsToken */, - "@": 54 /* AtToken */ + ">>": 44 /* GreaterThanGreaterThanToken */, + ">>>": 45 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 46 /* AmpersandToken */, + "|": 47 /* BarToken */, + "^": 48 /* CaretToken */, + "!": 49 /* ExclamationToken */, + "~": 50 /* TildeToken */, + "&&": 51 /* AmpersandAmpersandToken */, + "||": 52 /* BarBarToken */, + "?": 53 /* QuestionToken */, + ":": 54 /* ColonToken */, + "=": 56 /* EqualsToken */, + "+=": 57 /* PlusEqualsToken */, + "-=": 58 /* MinusEqualsToken */, + "*=": 59 /* AsteriskEqualsToken */, + "**=": 60 /* AsteriskAsteriskEqualsToken */, + "/=": 61 /* SlashEqualsToken */, + "%=": 62 /* PercentEqualsToken */, + "<<=": 63 /* LessThanLessThanEqualsToken */, + ">>=": 64 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 66 /* AmpersandEqualsToken */, + "|=": 67 /* BarEqualsToken */, + "^=": 68 /* CaretEqualsToken */, + "@": 55 /* AtToken */ }; /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers @@ -3123,8 +3142,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 67 /* Identifier */ || token > 103 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 68 /* FirstReservedWord */ && token <= 103 /* LastReservedWord */; }, + isIdentifier: function () { return token === 69 /* Identifier */ || token > 105 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 70 /* FirstReservedWord */ && token <= 105 /* LastReservedWord */; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -3146,16 +3165,6 @@ var ts; onError(message, length || 0); } } - function isIdentifierStart(ch) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); - } - function isIdentifierPart(ch) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); - } function scanNumber() { var start = pos; while (isDigit(text.charCodeAt(pos))) @@ -3438,12 +3447,12 @@ var ts; var start = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (isIdentifierPart(ch)) { + if (isIdentifierPart(ch, languageVersion)) { pos++; } else if (ch === 92 /* backslash */) { ch = peekUnicodeEscape(); - if (!(ch >= 0 && isIdentifierPart(ch))) { + if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } result += text.substring(start, pos); @@ -3468,7 +3477,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 67 /* Identifier */; + return token = 69 /* Identifier */; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -3552,7 +3561,7 @@ var ts; } return pos += 2, token = 31 /* ExclamationEqualsToken */; } - return pos++, token = 48 /* ExclamationToken */; + return pos++, token = 49 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -3561,42 +3570,48 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 60 /* PercentEqualsToken */; + return pos += 2, token = 62 /* PercentEqualsToken */; } - return pos++, token = 39 /* PercentToken */; + return pos++, token = 40 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 50 /* AmpersandAmpersandToken */; + return pos += 2, token = 51 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* AmpersandEqualsToken */; + return pos += 2, token = 66 /* AmpersandEqualsToken */; } - return pos++, token = 45 /* AmpersandToken */; + return pos++, token = 46 /* AmpersandToken */; case 40 /* openParen */: return pos++, token = 17 /* OpenParenToken */; case 41 /* closeParen */: return pos++, token = 18 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* AsteriskEqualsToken */; + return pos += 2, token = 59 /* AsteriskEqualsToken */; + } + if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 2) === 61 /* equals */) { + return pos += 3, token = 60 /* AsteriskAsteriskEqualsToken */; + } + return pos += 2, token = 38 /* AsteriskAsteriskToken */; } return pos++, token = 37 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 40 /* PlusPlusToken */; + return pos += 2, token = 41 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 56 /* PlusEqualsToken */; + return pos += 2, token = 57 /* PlusEqualsToken */; } return pos++, token = 35 /* PlusToken */; case 44 /* comma */: return pos++, token = 24 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 41 /* MinusMinusToken */; + return pos += 2, token = 42 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 57 /* MinusEqualsToken */; + return pos += 2, token = 58 /* MinusEqualsToken */; } return pos++, token = 36 /* MinusToken */; case 46 /* dot */: @@ -3653,9 +3668,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* SlashEqualsToken */; + return pos += 2, token = 61 /* SlashEqualsToken */; } - return pos++, token = 38 /* SlashToken */; + return pos++, token = 39 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -3707,7 +3722,7 @@ var ts; tokenValue = "" + scanNumber(); return token = 8 /* NumericLiteral */; case 58 /* colon */: - return pos++, token = 53 /* ColonToken */; + return pos++, token = 54 /* ColonToken */; case 59 /* semicolon */: return pos++, token = 23 /* SemicolonToken */; case 60 /* lessThan */: @@ -3722,14 +3737,16 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 61 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 63 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 42 /* LessThanLessThanToken */; + return pos += 2, token = 43 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { return pos += 2, token = 28 /* LessThanEqualsToken */; } - if (text.charCodeAt(pos + 1) === 47 /* slash */ && languageVariant === 1 /* JSX */) { + if (languageVariant === 1 /* JSX */ && + text.charCodeAt(pos + 1) === 47 /* slash */ && + text.charCodeAt(pos + 2) !== 42 /* asterisk */) { return pos += 2, token = 26 /* LessThanSlashToken */; } return pos++, token = 25 /* LessThanToken */; @@ -3752,7 +3769,7 @@ var ts; if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { return pos += 2, token = 34 /* EqualsGreaterThanToken */; } - return pos++, token = 55 /* EqualsToken */; + return pos++, token = 56 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3765,35 +3782,35 @@ var ts; } return pos++, token = 27 /* GreaterThanToken */; case 63 /* question */: - return pos++, token = 52 /* QuestionToken */; + return pos++, token = 53 /* QuestionToken */; case 91 /* openBracket */: return pos++, token = 19 /* OpenBracketToken */; case 93 /* closeBracket */: return pos++, token = 20 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* CaretEqualsToken */; + return pos += 2, token = 68 /* CaretEqualsToken */; } - return pos++, token = 47 /* CaretToken */; + return pos++, token = 48 /* CaretToken */; case 123 /* openBrace */: return pos++, token = 15 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 51 /* BarBarToken */; + return pos += 2, token = 52 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* BarEqualsToken */; + return pos += 2, token = 67 /* BarEqualsToken */; } - return pos++, token = 46 /* BarToken */; + return pos++, token = 47 /* BarToken */; case 125 /* closeBrace */: return pos++, token = 16 /* CloseBraceToken */; case 126 /* tilde */: - return pos++, token = 49 /* TildeToken */; + return pos++, token = 50 /* TildeToken */; case 64 /* at */: - return pos++, token = 54 /* AtToken */; + return pos++, token = 55 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); @@ -3801,9 +3818,9 @@ var ts; error(ts.Diagnostics.Invalid_character); return pos++, token = 0 /* Unknown */; default: - if (isIdentifierStart(ch)) { + if (isIdentifierStart(ch, languageVersion)) { pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos))) + while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) pos++; tokenValue = text.substring(tokenPos, pos); if (ch === 92 /* backslash */) { @@ -3830,14 +3847,14 @@ var ts; if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 44 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 45 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 64 /* GreaterThanGreaterThanEqualsToken */; } - return pos++, token = 43 /* GreaterThanGreaterThanToken */; + return pos++, token = 44 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { return pos++, token = 29 /* GreaterThanEqualsToken */; @@ -3846,7 +3863,7 @@ var ts; return token; } function reScanSlashToken() { - if (token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) { + if (token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -3886,7 +3903,7 @@ var ts; } p++; } - while (p < end && isIdentifierPart(text.charCodeAt(p))) { + while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { p++; } pos = p; @@ -3932,7 +3949,7 @@ var ts; break; } } - return token = 234 /* JsxText */; + return token = 236 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -3941,7 +3958,7 @@ var ts; var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) { + if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { pos++; } else { @@ -4020,16 +4037,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 214 /* TypeAliasDeclaration */) { + if (node.kind === 215 /* InterfaceDeclaration */ || node.kind === 216 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 217 /* ModuleBlock */) { + else if (node.kind === 219 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -4048,7 +4065,7 @@ var ts; }); return state; } - else if (node.kind === 216 /* ModuleDeclaration */) { + else if (node.kind === 218 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -4088,6 +4105,8 @@ var ts; var container; var blockScopeContainer; var lastContainer; + var seenThisKeyword; + var isJavaScriptFile = ts.isSourceFileJavaScript(file); // If this file is an external module, then it is automatically in strict-mode according to // ES6. If it is not an external module, then we'll determine if it is in strict mode or // not depending on if we see "use strict" in certain places (or if we hit a class/namespace). @@ -4126,10 +4145,10 @@ var ts; // unless it is a well known Symbol. function getDeclarationName(node) { if (node.name) { - if (node.kind === 216 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 218 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return "\"" + node.name.text + "\""; } - if (node.name.kind === 134 /* ComputedPropertyName */) { + if (node.name.kind === 136 /* ComputedPropertyName */) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -4137,22 +4156,25 @@ var ts; return node.name.text; } switch (node.kind) { - case 142 /* Constructor */: + case 144 /* Constructor */: return "__constructor"; - case 150 /* FunctionType */: - case 145 /* CallSignature */: + case 152 /* FunctionType */: + case 147 /* CallSignature */: return "__call"; - case 151 /* ConstructorType */: - case 146 /* ConstructSignature */: + case 153 /* ConstructorType */: + case 148 /* ConstructSignature */: return "__new"; - case 147 /* IndexSignature */: + case 149 /* IndexSignature */: return "__index"; - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return "__export"; - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 211 /* FunctionDeclaration */: - case 212 /* ClassDeclaration */: + case 181 /* BinaryExpression */: + // Binary expression case is for JS module 'module.exports = expr' + return "export="; + case 213 /* FunctionDeclaration */: + case 214 /* ClassDeclaration */: return node.flags & 1024 /* Default */ ? "default" : undefined; } } @@ -4169,8 +4191,9 @@ var ts; */ function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); + var isDefaultExport = node.flags & 1024 /* Default */; // The exported symbol for an export default function/class node is always named "default" - var name = node.flags & 1024 /* Default */ && parent ? "default" : getDeclarationName(node); + var name = isDefaultExport && parent ? "default" : getDeclarationName(node); var symbol; if (name !== undefined) { // Check and see if the symbol table already has a symbol with this name. If not, @@ -4206,6 +4229,11 @@ var ts; var message = symbol.flags & 2 /* BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; + ts.forEach(symbol.declarations, function (declaration) { + if (declaration.flags & 1024 /* Default */) { + message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + } + }); ts.forEach(symbol.declarations, function (declaration) { file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); }); @@ -4223,7 +4251,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 228 /* ExportSpecifier */ || (node.kind === 219 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 230 /* ExportSpecifier */ || (node.kind === 221 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -4297,44 +4325,51 @@ var ts; blockScopeContainer = node; blockScopeContainer.locals = undefined; } - ts.forEachChild(node, bind); + if (node.kind === 215 /* InterfaceDeclaration */) { + seenThisKeyword = false; + ts.forEachChild(node, bind); + node.flags = seenThisKeyword ? node.flags | 524288 /* ContainsThis */ : node.flags & ~524288 /* ContainsThis */; + } + else { + ts.forEachChild(node, bind); + } container = saveContainer; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } function getContainerFlags(node) { switch (node.kind) { - case 184 /* ClassExpression */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 153 /* TypeLiteral */: - case 163 /* ObjectLiteralExpression */: + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 155 /* TypeLiteral */: + case 165 /* ObjectLiteralExpression */: return 1 /* IsContainer */; - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 211 /* FunctionDeclaration */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 216 /* ModuleDeclaration */: - case 246 /* SourceFile */: - case 214 /* TypeAliasDeclaration */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 213 /* FunctionDeclaration */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 218 /* ModuleDeclaration */: + case 248 /* SourceFile */: + case 216 /* TypeAliasDeclaration */: return 5 /* IsContainerWithLocals */; - case 242 /* CatchClause */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 218 /* CaseBlock */: + case 244 /* CatchClause */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 220 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 190 /* Block */: + case 192 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Othewise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -4371,38 +4406,38 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 246 /* SourceFile */: + case 248 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 184 /* ClassExpression */: - case 212 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 153 /* TypeLiteral */: - case 163 /* ObjectLiteralExpression */: - case 213 /* InterfaceDeclaration */: + case 155 /* TypeLiteral */: + case 165 /* ObjectLiteralExpression */: + case 215 /* InterfaceDeclaration */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 214 /* TypeAliasDeclaration */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 216 /* TypeAliasDeclaration */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -4432,11 +4467,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 246 /* SourceFile */ ? node : node.body; - if (body.kind === 246 /* SourceFile */ || body.kind === 217 /* ModuleBlock */) { + var body = node.kind === 248 /* SourceFile */ ? node : node.body; + if (body.kind === 248 /* SourceFile */ || body.kind === 219 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 226 /* ExportDeclaration */ || stat.kind === 225 /* ExportAssignment */) { + if (stat.kind === 228 /* ExportDeclaration */ || stat.kind === 227 /* ExportAssignment */) { return true; } } @@ -4508,7 +4543,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 67 /* Identifier */) { + if (prop.name.kind !== 69 /* Identifier */) { continue; } var identifier = prop.name; @@ -4520,7 +4555,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */ || prop.kind === 141 /* MethodDeclaration */ + var currentKind = prop.kind === 245 /* PropertyAssignment */ || prop.kind === 246 /* ShorthandPropertyAssignment */ || prop.kind === 143 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -4542,10 +4577,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 246 /* SourceFile */: + case 248 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -4566,8 +4601,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 104 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 112 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 106 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 114 /* LastFutureReservedWord */ && !ts.isIdentifierName(node)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { @@ -4602,7 +4637,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 67 /* Identifier */) { + if (inStrictMode && node.expression.kind === 69 /* Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -4610,11 +4645,11 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 67 /* Identifier */ && + return node.kind === 69 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 67 /* Identifier */) { + if (name && name.kind === 69 /* Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -4658,7 +4693,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 40 /* PlusPlusToken */ || node.operator === 41 /* MinusMinusToken */) { + if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -4702,17 +4737,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 246 /* SourceFile */: - case 217 /* ModuleBlock */: + case 248 /* SourceFile */: + case 219 /* ModuleBlock */: updateStrictModeStatementList(node.statements); return; - case 190 /* Block */: + case 192 /* Block */: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return; @@ -4739,107 +4774,130 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 67 /* Identifier */: + /* Strict mode checks */ + case 69 /* Identifier */: return checkStrictModeIdentifier(node); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: + if (isJavaScriptFile) { + if (ts.isExportsPropertyAssignment(node)) { + bindExportsPropertyAssignment(node); + } + else if (ts.isModuleExportsAssignment(node)) { + bindModuleExportsAssignment(node); + } + } return checkStrictModeBinaryExpression(node); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return checkStrictModeCatchClause(node); - case 173 /* DeleteExpression */: + case 175 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 178 /* PostfixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 203 /* WithStatement */: + case 205 /* WithStatement */: return checkStrictModeWithStatement(node); - case 135 /* TypeParameter */: + case 97 /* ThisKeyword */: + seenThisKeyword = true; + return; + case 137 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 136 /* Parameter */: + case 138 /* Parameter */: return bindParameter(node); - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 243 /* PropertyAssignment */: - case 244 /* ShorthandPropertyAssignment */: + case 245 /* PropertyAssignment */: + case 246 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 245 /* EnumMember */: + case 247 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); - case 142 /* Constructor */: + case 144 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 143 /* GetAccessor */: + case 145 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 144 /* SetAccessor */: + case 146 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 153 /* TypeLiteral */: + case 155 /* TypeLiteral */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); - case 184 /* ClassExpression */: - case 212 /* ClassDeclaration */: + case 168 /* CallExpression */: + if (isJavaScriptFile) { + bindCallExpression(node); + } + break; + // Members of classes, interfaces, and modules + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: return bindClassLikeDeclaration(node); - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */); - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return bindModuleDeclaration(node); - case 219 /* ImportEqualsDeclaration */: - case 222 /* NamespaceImport */: - case 224 /* ImportSpecifier */: - case 228 /* ExportSpecifier */: + // Imports and exports + case 221 /* ImportEqualsDeclaration */: + case 224 /* NamespaceImport */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 221 /* ImportClause */: + case 223 /* ImportClause */: return bindImportClause(node); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return bindExportDeclaration(node); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return bindExportAssignment(node); - case 246 /* SourceFile */: + case 248 /* SourceFile */: return bindSourceFileIfExternalModule(); } } function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); + bindSourceFileAsExternalModule(); } } + function bindSourceFileAsExternalModule() { + bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); + } function bindExportAssignment(node) { + var boundExpression = node.kind === 227 /* ExportAssignment */ ? node.expression : node.right; if (!container.symbol || !container.symbol.exports) { // Export assignment in some sort of block construct bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); } - else if (node.expression.kind === 67 /* Identifier */) { + else if (boundExpression.kind === 69 /* Identifier */) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* Alias */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); } @@ -4863,8 +4921,32 @@ var ts; declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); } } + function setCommonJsModuleIndicator(node) { + if (!file.commonJsModuleIndicator) { + file.commonJsModuleIndicator = node; + bindSourceFileAsExternalModule(); + } + } + function bindExportsPropertyAssignment(node) { + // When we create a property via 'exports.foo = bar', the 'exports.foo' property access + // expression is the declaration + setCommonJsModuleIndicator(node); + declareSymbol(file.symbol.exports, file.symbol, node.left, 4 /* Property */ | 7340032 /* Export */, 0 /* None */); + } + function bindModuleExportsAssignment(node) { + // 'module.exports = expr' assignment + setCommonJsModuleIndicator(node); + bindExportAssignment(node); + } + function bindCallExpression(node) { + // We're only inspecting call expressions to detect CommonJS modules, so we can skip + // this check if we've already seen the module indicator + if (!file.commonJsModuleIndicator && ts.isRequireCall(node)) { + setCommonJsModuleIndicator(node); + } + } function bindClassLikeDeclaration(node) { - if (node.kind === 212 /* ClassDeclaration */) { + if (node.kind === 214 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -4940,7 +5022,7 @@ var ts; // If this is a property-parameter, then also declare the property symbol into the // containing class. if (node.flags & 112 /* AccessibilityModifier */ && - node.parent.kind === 142 /* Constructor */ && + node.parent.kind === 144 /* Constructor */ && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); @@ -4992,7 +5074,8 @@ var ts; increaseIndent: function () { }, decreaseIndent: function () { }, clear: function () { return str = ""; }, - trackSymbol: function () { } + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } }; } return stringWriters.pop(); @@ -5062,7 +5145,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 246 /* SourceFile */) { + while (node && node.kind !== 248 /* SourceFile */) { node = node.parent; } return node; @@ -5174,15 +5257,15 @@ var ts; return current; } switch (current.kind) { - case 246 /* SourceFile */: - case 218 /* CaseBlock */: - case 242 /* CatchClause */: - case 216 /* ModuleDeclaration */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 248 /* SourceFile */: + case 220 /* CaseBlock */: + case 244 /* CatchClause */: + case 218 /* ModuleDeclaration */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: return current; - case 190 /* Block */: + case 192 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -5195,9 +5278,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 209 /* VariableDeclaration */ && + declaration.kind === 211 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 242 /* CatchClause */; + declaration.parent.kind === 244 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -5236,7 +5319,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 246 /* SourceFile */: + case 248 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -5245,16 +5328,16 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 213 /* InterfaceDeclaration */: - case 216 /* ModuleDeclaration */: - case 215 /* EnumDeclaration */: - case 245 /* EnumMember */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 218 /* ModuleDeclaration */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: errorNode = node.name; break; } @@ -5273,16 +5356,20 @@ var ts; return file.externalModuleIndicator !== undefined; } ts.isExternalModule = isExternalModule; + function isExternalOrCommonJsModule(file) { + return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; + } + ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isDeclarationFile(file) { return (file.flags & 8192 /* DeclarationFile */) !== 0; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 215 /* EnumDeclaration */ && isConst(node); + return node.kind === 217 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 161 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 163 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; @@ -5297,14 +5384,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 209 /* VariableDeclaration */) { + if (node.kind === 211 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 210 /* VariableDeclarationList */) { + if (node && node.kind === 212 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 191 /* VariableStatement */) { + if (node && node.kind === 193 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -5319,7 +5406,7 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 193 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; + return node.kind === 195 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -5327,7 +5414,7 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - var commentRanges = (node.kind === 136 /* Parameter */ || node.kind === 135 /* TypeParameter */) ? + var commentRanges = (node.kind === 138 /* Parameter */ || node.kind === 137 /* TypeParameter */) ? ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : getLeadingCommentRangesOfNode(node, sourceFileOfNode); return ts.filter(commentRanges, isJsDocComment); @@ -5342,40 +5429,40 @@ var ts; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (149 /* FirstTypeNode */ <= node.kind && node.kind <= 158 /* LastTypeNode */) { + if (151 /* FirstTypeNode */ <= node.kind && node.kind <= 160 /* LastTypeNode */) { return true; } switch (node.kind) { - case 115 /* AnyKeyword */: - case 126 /* NumberKeyword */: - case 128 /* StringKeyword */: - case 118 /* BooleanKeyword */: - case 129 /* SymbolKeyword */: + case 117 /* AnyKeyword */: + case 128 /* NumberKeyword */: + case 130 /* StringKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: return true; - case 101 /* VoidKeyword */: - return node.parent.kind !== 175 /* VoidExpression */; + case 103 /* VoidKeyword */: + return node.parent.kind !== 177 /* VoidExpression */; case 9 /* StringLiteral */: // Specialized signatures can have string literals as their parameters' type names - return node.parent.kind === 136 /* Parameter */; - case 186 /* ExpressionWithTypeArguments */: + return node.parent.kind === 138 /* Parameter */; + case 188 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 67 /* Identifier */: + case 69 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } - // fall through - case 133 /* QualifiedName */: - case 164 /* PropertyAccessExpression */: // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */ || node.kind === 166 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 135 /* QualifiedName */: + case 166 /* PropertyAccessExpression */: + case 97 /* ThisKeyword */: var parent_1 = node.parent; - if (parent_1.kind === 152 /* TypeQuery */) { + if (parent_1.kind === 154 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -5384,38 +5471,38 @@ var ts; // // Calling isTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (149 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 158 /* LastTypeNode */) { + if (151 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 160 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 135 /* TypeParameter */: + case 137 /* TypeParameter */: return node === parent_1.constraint; - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 136 /* Parameter */: - case 209 /* VariableDeclaration */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 138 /* Parameter */: + case 211 /* VariableDeclaration */: return node === parent_1.type; - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 142 /* Constructor */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 144 /* Constructor */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return node === parent_1.type; - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: return node === parent_1.type; - case 169 /* TypeAssertionExpression */: + case 171 /* TypeAssertionExpression */: return node === parent_1.type; - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 168 /* TaggedTemplateExpression */: + case 170 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -5429,23 +5516,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 202 /* ReturnStatement */: + case 204 /* ReturnStatement */: return visitor(node); - case 218 /* CaseBlock */: - case 190 /* Block */: - case 194 /* IfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 203 /* WithStatement */: - case 204 /* SwitchStatement */: - case 239 /* CaseClause */: - case 240 /* DefaultClause */: - case 205 /* LabeledStatement */: - case 207 /* TryStatement */: - case 242 /* CatchClause */: + case 220 /* CaseBlock */: + case 192 /* Block */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 205 /* WithStatement */: + case 206 /* SwitchStatement */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + case 207 /* LabeledStatement */: + case 209 /* TryStatement */: + case 244 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -5455,18 +5542,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 182 /* YieldExpression */: + case 184 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 215 /* EnumDeclaration */: - case 213 /* InterfaceDeclaration */: - case 216 /* ModuleDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: + case 218 /* ModuleDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. @@ -5474,7 +5561,7 @@ var ts; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 134 /* ComputedPropertyName */) { + if (name_5 && name_5.kind === 136 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(name_5.expression); @@ -5493,14 +5580,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 161 /* BindingElement */: - case 245 /* EnumMember */: - case 136 /* Parameter */: - case 243 /* PropertyAssignment */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 244 /* ShorthandPropertyAssignment */: - case 209 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 247 /* EnumMember */: + case 138 /* Parameter */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 246 /* ShorthandPropertyAssignment */: + case 211 /* VariableDeclaration */: return true; } } @@ -5508,29 +5595,29 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* SetAccessor */); + return node && (node.kind === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */); + return node && (node.kind === 214 /* ClassDeclaration */ || node.kind === 186 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 142 /* Constructor */: - case 171 /* FunctionExpression */: - case 211 /* FunctionDeclaration */: - case 172 /* ArrowFunction */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: - case 150 /* FunctionType */: - case 151 /* ConstructorType */: + case 144 /* Constructor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: return true; } } @@ -5539,24 +5626,24 @@ var ts; ts.isFunctionLike = isFunctionLike; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: return true; } return false; } ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 190 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 192 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 141 /* MethodDeclaration */ && node.parent.kind === 163 /* ObjectLiteralExpression */; + return node && node.kind === 143 /* MethodDeclaration */ && node.parent.kind === 165 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -5584,7 +5671,7 @@ var ts; return undefined; } switch (node.kind) { - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -5599,9 +5686,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 137 /* Decorator */: + case 139 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 136 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 138 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5612,23 +5699,26 @@ var ts; node = node.parent; } break; - case 172 /* ArrowFunction */: + case 174 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 216 /* ModuleDeclaration */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 215 /* EnumDeclaration */: - case 246 /* SourceFile */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 218 /* ModuleDeclaration */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 217 /* EnumDeclaration */: + case 248 /* SourceFile */: return node; } } @@ -5640,7 +5730,7 @@ var ts; if (!node) return node; switch (node.kind) { - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'super' container. // A computed property name in a class needs to be a super container @@ -5655,9 +5745,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 137 /* Decorator */: + case 139 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 136 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 138 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5668,19 +5758,19 @@ var ts; node = node.parent; } break; - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: if (!includeFunctions) { continue; } - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return node; } } @@ -5689,12 +5779,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 149 /* TypeReference */: + case 151 /* TypeReference */: return node.typeName; - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return node.expression; - case 67 /* Identifier */: - case 133 /* QualifiedName */: + case 69 /* Identifier */: + case 135 /* QualifiedName */: return node; } } @@ -5702,7 +5792,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 168 /* TaggedTemplateExpression */) { + if (node.kind === 170 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -5711,44 +5801,44 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: // classes are valid targets return true; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 212 /* ClassDeclaration */; - case 136 /* Parameter */: + return node.parent.kind === 214 /* ClassDeclaration */; + case 138 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; - return node.parent.body && node.parent.parent.kind === 212 /* ClassDeclaration */; - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 141 /* MethodDeclaration */: + return node.parent.body && node.parent.parent.kind === 214 /* ClassDeclaration */; + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 143 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. - return node.body && node.parent.kind === 212 /* ClassDeclaration */; + return node.body && node.parent.kind === 214 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: if (node.decorators) { return true; } return false; - case 139 /* PropertyDeclaration */: - case 136 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 138 /* Parameter */: if (node.decorators) { return true; } return false; - case 143 /* GetAccessor */: + case 145 /* GetAccessor */: if (node.body && node.decorators) { return true; } return false; - case 141 /* MethodDeclaration */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 146 /* SetAccessor */: if (node.body && node.decorators) { return true; } @@ -5759,10 +5849,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 141 /* MethodDeclaration */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 146 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -5772,96 +5862,106 @@ var ts; return nodeIsDecorated(node) || childIsDecorated(node); } ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; + function isPropertyAccessExpression(node) { + return node.kind === 166 /* PropertyAccessExpression */; + } + ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isElementAccessExpression(node) { + return node.kind === 167 /* ElementAccessExpression */; + } + ts.isElementAccessExpression = isElementAccessExpression; function isExpression(node) { switch (node.kind) { - case 95 /* ThisKeyword */: - case 93 /* SuperKeyword */: - case 91 /* NullKeyword */: - case 97 /* TrueKeyword */: - case 82 /* FalseKeyword */: + case 95 /* SuperKeyword */: + case 93 /* NullKeyword */: + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: case 10 /* RegularExpressionLiteral */: - case 162 /* ArrayLiteralExpression */: - case 163 /* ObjectLiteralExpression */: - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 168 /* TaggedTemplateExpression */: - case 187 /* AsExpression */: - case 169 /* TypeAssertionExpression */: - case 170 /* ParenthesizedExpression */: - case 171 /* FunctionExpression */: - case 184 /* ClassExpression */: - case 172 /* ArrowFunction */: - case 175 /* VoidExpression */: - case 173 /* DeleteExpression */: - case 174 /* TypeOfExpression */: - case 177 /* PrefixUnaryExpression */: - case 178 /* PostfixUnaryExpression */: - case 179 /* BinaryExpression */: - case 180 /* ConditionalExpression */: - case 183 /* SpreadElementExpression */: - case 181 /* TemplateExpression */: + case 164 /* ArrayLiteralExpression */: + case 165 /* ObjectLiteralExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 170 /* TaggedTemplateExpression */: + case 189 /* AsExpression */: + case 171 /* TypeAssertionExpression */: + case 172 /* ParenthesizedExpression */: + case 173 /* FunctionExpression */: + case 186 /* ClassExpression */: + case 174 /* ArrowFunction */: + case 177 /* VoidExpression */: + case 175 /* DeleteExpression */: + case 176 /* TypeOfExpression */: + case 179 /* PrefixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: + case 181 /* BinaryExpression */: + case 182 /* ConditionalExpression */: + case 185 /* SpreadElementExpression */: + case 183 /* TemplateExpression */: case 11 /* NoSubstitutionTemplateLiteral */: - case 185 /* OmittedExpression */: - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - case 182 /* YieldExpression */: + case 187 /* OmittedExpression */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 184 /* YieldExpression */: + case 178 /* AwaitExpression */: return true; - case 133 /* QualifiedName */: - while (node.parent.kind === 133 /* QualifiedName */) { + case 135 /* QualifiedName */: + while (node.parent.kind === 135 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 152 /* TypeQuery */; - case 67 /* Identifier */: - if (node.parent.kind === 152 /* TypeQuery */) { + return node.parent.kind === 154 /* TypeQuery */; + case 69 /* Identifier */: + if (node.parent.kind === 154 /* TypeQuery */) { return true; } // fall through case 8 /* NumericLiteral */: case 9 /* StringLiteral */: + case 97 /* ThisKeyword */: var parent_2 = node.parent; switch (parent_2.kind) { - case 209 /* VariableDeclaration */: - case 136 /* Parameter */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 245 /* EnumMember */: - case 243 /* PropertyAssignment */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 247 /* EnumMember */: + case 245 /* PropertyAssignment */: + case 163 /* BindingElement */: return parent_2.initializer === node; - case 193 /* ExpressionStatement */: - case 194 /* IfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 202 /* ReturnStatement */: - case 203 /* WithStatement */: - case 204 /* SwitchStatement */: - case 239 /* CaseClause */: - case 206 /* ThrowStatement */: - case 204 /* SwitchStatement */: + case 195 /* ExpressionStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 204 /* ReturnStatement */: + case 205 /* WithStatement */: + case 206 /* SwitchStatement */: + case 241 /* CaseClause */: + case 208 /* ThrowStatement */: + case 206 /* SwitchStatement */: return parent_2.expression === node; - case 197 /* ForStatement */: + case 199 /* ForStatement */: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 210 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 212 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 212 /* VariableDeclarationList */) || forInStatement.expression === node; - case 169 /* TypeAssertionExpression */: - case 187 /* AsExpression */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: return node === parent_2.expression; - case 188 /* TemplateSpan */: + case 190 /* TemplateSpan */: return node === parent_2.expression; - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: return node === parent_2.expression; - case 137 /* Decorator */: - case 238 /* JsxExpression */: + case 139 /* Decorator */: + case 240 /* JsxExpression */: + case 239 /* JsxSpreadAttribute */: return true; - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -5872,6 +5972,12 @@ var ts; return false; } ts.isExpression = isExpression; + function isExternalModuleNameRelative(moduleName) { + // TypeScript 1.0 spec (April 2014): 11.2.1 + // An external module name is "relative" if the first term is "." or "..". + return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); return moduleState === 1 /* Instantiated */ || @@ -5879,7 +5985,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */; + return node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 232 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5888,20 +5994,70 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 230 /* ExternalModuleReference */; + return node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 232 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; + function isSourceFileJavaScript(file) { + return isInJavaScriptFile(file); + } + ts.isSourceFileJavaScript = isSourceFileJavaScript; + function isInJavaScriptFile(node) { + return node && !!(node.parserContextFlags & 32 /* JavaScriptFile */); + } + ts.isInJavaScriptFile = isInJavaScriptFile; + /** + * Returns true if the node is a CallExpression to the identifier 'require' with + * exactly one argument. + * This function does not test if the node is in a JavaScript file or not. + */ + function isRequireCall(expression) { + // of the form 'require("name")' + return expression.kind === 168 /* CallExpression */ && + expression.expression.kind === 69 /* Identifier */ && + expression.expression.text === "require" && + expression.arguments.length === 1; + } + ts.isRequireCall = isRequireCall; + /** + * Returns true if the node is an assignment to a property on the identifier 'exports'. + * This function does not test if the node is in a JavaScript file or not. + */ + function isExportsPropertyAssignment(expression) { + // of the form 'exports.name = expr' where 'name' and 'expr' are arbitrary + return isInJavaScriptFile(expression) && + (expression.kind === 181 /* BinaryExpression */) && + (expression.operatorToken.kind === 56 /* EqualsToken */) && + (expression.left.kind === 166 /* PropertyAccessExpression */) && + (expression.left.expression.kind === 69 /* Identifier */) && + ((expression.left.expression).text === "exports"); + } + ts.isExportsPropertyAssignment = isExportsPropertyAssignment; + /** + * Returns true if the node is an assignment to the property access expression 'module.exports'. + * This function does not test if the node is in a JavaScript file or not. + */ + function isModuleExportsAssignment(expression) { + // of the form 'module.exports = expr' where 'expr' is arbitrary + return isInJavaScriptFile(expression) && + (expression.kind === 181 /* BinaryExpression */) && + (expression.operatorToken.kind === 56 /* EqualsToken */) && + (expression.left.kind === 166 /* PropertyAccessExpression */) && + (expression.left.expression.kind === 69 /* Identifier */) && + ((expression.left.expression).text === "module") && + (expression.left.name.text === "exports"); + } + ts.isModuleExportsAssignment = isModuleExportsAssignment; function getExternalModuleName(node) { - if (node.kind === 220 /* ImportDeclaration */) { + if (node.kind === 222 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 219 /* ImportEqualsDeclaration */) { + if (node.kind === 221 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 230 /* ExternalModuleReference */) { + if (reference.kind === 232 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 226 /* ExportDeclaration */) { + if (node.kind === 228 /* ExportDeclaration */) { return node.moduleSpecifier; } } @@ -5909,13 +6065,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 136 /* Parameter */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 244 /* ShorthandPropertyAssignment */: - case 243 /* PropertyAssignment */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 138 /* Parameter */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 246 /* ShorthandPropertyAssignment */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -5923,9 +6079,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 259 /* JSDocFunctionType */ && + return node.kind === 261 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 261 /* JSDocConstructorType */; + node.parameters[0].type.kind === 263 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -5939,26 +6095,26 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 267 /* JSDocTypeTag */); + return getJSDocTag(node, 269 /* JSDocTypeTag */); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 266 /* JSDocReturnTag */); + return getJSDocTag(node, 268 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 268 /* JSDocTemplateTag */); + return getJSDocTag(node, 270 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 67 /* Identifier */) { + if (parameter.name && parameter.name.kind === 69 /* Identifier */) { // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 265 /* JSDocParameterTag */) { + if (t.kind === 267 /* JSDocParameterTag */) { var parameterTag = t; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { @@ -5977,12 +6133,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32 /* JavaScriptFile */) { - if (node.type && node.type.kind === 260 /* JSDocVariadicType */) { + if (node.type && node.type.kind === 262 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 260 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 262 /* JSDocVariadicType */; } } return node.dotDotDotToken !== undefined; @@ -6003,7 +6159,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 160 /* ArrayBindingPattern */ || node.kind === 159 /* ObjectBindingPattern */); + return !!node && (node.kind === 162 /* ArrayBindingPattern */ || node.kind === 161 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -6018,34 +6174,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 172 /* ArrowFunction */: - case 161 /* BindingElement */: - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 142 /* Constructor */: - case 215 /* EnumDeclaration */: - case 245 /* EnumMember */: - case 228 /* ExportSpecifier */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 143 /* GetAccessor */: - case 221 /* ImportClause */: - case 219 /* ImportEqualsDeclaration */: - case 224 /* ImportSpecifier */: - case 213 /* InterfaceDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 216 /* ModuleDeclaration */: - case 222 /* NamespaceImport */: - case 136 /* Parameter */: - case 243 /* PropertyAssignment */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 144 /* SetAccessor */: - case 244 /* ShorthandPropertyAssignment */: - case 214 /* TypeAliasDeclaration */: - case 135 /* TypeParameter */: - case 209 /* VariableDeclaration */: + case 174 /* ArrowFunction */: + case 163 /* BindingElement */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 144 /* Constructor */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 230 /* ExportSpecifier */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 145 /* GetAccessor */: + case 223 /* ImportClause */: + case 221 /* ImportEqualsDeclaration */: + case 226 /* ImportSpecifier */: + case 215 /* InterfaceDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 218 /* ModuleDeclaration */: + case 224 /* NamespaceImport */: + case 138 /* Parameter */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 146 /* SetAccessor */: + case 246 /* ShorthandPropertyAssignment */: + case 216 /* TypeAliasDeclaration */: + case 137 /* TypeParameter */: + case 211 /* VariableDeclaration */: return true; } return false; @@ -6053,25 +6209,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 201 /* BreakStatement */: - case 200 /* ContinueStatement */: - case 208 /* DebuggerStatement */: - case 195 /* DoStatement */: - case 193 /* ExpressionStatement */: - case 192 /* EmptyStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 197 /* ForStatement */: - case 194 /* IfStatement */: - case 205 /* LabeledStatement */: - case 202 /* ReturnStatement */: - case 204 /* SwitchStatement */: - case 96 /* ThrowKeyword */: - case 207 /* TryStatement */: - case 191 /* VariableStatement */: - case 196 /* WhileStatement */: - case 203 /* WithStatement */: - case 225 /* ExportAssignment */: + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 210 /* DebuggerStatement */: + case 197 /* DoStatement */: + case 195 /* ExpressionStatement */: + case 194 /* EmptyStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 199 /* ForStatement */: + case 196 /* IfStatement */: + case 207 /* LabeledStatement */: + case 204 /* ReturnStatement */: + case 206 /* SwitchStatement */: + case 98 /* ThrowKeyword */: + case 209 /* TryStatement */: + case 193 /* VariableStatement */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 227 /* ExportAssignment */: return true; default: return false; @@ -6080,13 +6236,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 142 /* Constructor */: - case 139 /* PropertyDeclaration */: - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 140 /* MethodSignature */: - case 147 /* IndexSignature */: + case 144 /* Constructor */: + case 141 /* PropertyDeclaration */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 142 /* MethodSignature */: + case 149 /* IndexSignature */: return true; default: return false; @@ -6095,11 +6251,11 @@ var ts; ts.isClassElement = isClassElement; // True if the given identifier, string literal, or number literal is the name of a declaration node function isDeclarationName(name) { - if (name.kind !== 67 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { + if (name.kind !== 69 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { return false; } var parent = name.parent; - if (parent.kind === 224 /* ImportSpecifier */ || parent.kind === 228 /* ExportSpecifier */) { + if (parent.kind === 226 /* ImportSpecifier */ || parent.kind === 230 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -6114,31 +6270,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 245 /* EnumMember */: - case 243 /* PropertyAssignment */: - case 164 /* PropertyAccessExpression */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 247 /* EnumMember */: + case 245 /* PropertyAssignment */: + case 166 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 133 /* QualifiedName */: + case 135 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 133 /* QualifiedName */) { + while (parent.kind === 135 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 152 /* TypeQuery */; + return parent.kind === 154 /* TypeQuery */; } return false; - case 161 /* BindingElement */: - case 224 /* ImportSpecifier */: + case 163 /* BindingElement */: + case 226 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 228 /* ExportSpecifier */: + case 230 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -6154,26 +6310,26 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 219 /* ImportEqualsDeclaration */ || - node.kind === 221 /* ImportClause */ && !!node.name || - node.kind === 222 /* NamespaceImport */ || - node.kind === 224 /* ImportSpecifier */ || - node.kind === 228 /* ExportSpecifier */ || - node.kind === 225 /* ExportAssignment */ && node.expression.kind === 67 /* Identifier */; + return node.kind === 221 /* ImportEqualsDeclaration */ || + node.kind === 223 /* ImportClause */ && !!node.name || + node.kind === 224 /* NamespaceImport */ || + node.kind === 226 /* ImportSpecifier */ || + node.kind === 230 /* ExportSpecifier */ || + node.kind === 227 /* ExportAssignment */ && node.expression.kind === 69 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 104 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 106 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -6242,7 +6398,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 68 /* FirstKeyword */ <= token && token <= 132 /* LastKeyword */; + return 70 /* FirstKeyword */ <= token && token <= 134 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -6262,7 +6418,7 @@ var ts; */ function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 134 /* ComputedPropertyName */ && + declaration.name.kind === 136 /* ComputedPropertyName */ && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; @@ -6272,14 +6428,14 @@ var ts; * where Symbol is literally the word "Symbol", and name is any identifierName */ function isWellKnownSymbolSyntactically(node) { - return node.kind === 164 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); + return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 67 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { + if (name.kind === 69 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { return name.text; } - if (name.kind === 134 /* ComputedPropertyName */) { + if (name.kind === 136 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -6297,21 +6453,21 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 67 /* Identifier */ && node.text === "Symbol"; + return node.kind === 69 /* Identifier */ && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 113 /* AbstractKeyword */: - case 116 /* AsyncKeyword */: - case 72 /* ConstKeyword */: - case 120 /* DeclareKeyword */: - case 75 /* DefaultKeyword */: - case 80 /* ExportKeyword */: - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 111 /* StaticKeyword */: + case 115 /* AbstractKeyword */: + case 118 /* AsyncKeyword */: + case 74 /* ConstKeyword */: + case 122 /* DeclareKeyword */: + case 77 /* DefaultKeyword */: + case 82 /* ExportKeyword */: + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 113 /* StaticKeyword */: return true; } return false; @@ -6319,28 +6475,28 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 136 /* Parameter */; + return root.kind === 138 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 161 /* BindingElement */) { + while (node.kind === 163 /* BindingElement */) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 216 /* ModuleDeclaration */ || n.kind === 246 /* SourceFile */; + return isFunctionLike(n) || n.kind === 218 /* ModuleDeclaration */ || n.kind === 248 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function cloneEntityName(node) { - if (node.kind === 67 /* Identifier */) { - var clone_1 = createSynthesizedNode(67 /* Identifier */); + if (node.kind === 69 /* Identifier */) { + var clone_1 = createSynthesizedNode(69 /* Identifier */); clone_1.text = node.text; return clone_1; } else { - var clone_2 = createSynthesizedNode(133 /* QualifiedName */); + var clone_2 = createSynthesizedNode(135 /* QualifiedName */); clone_2.left = cloneEntityName(node.left); clone_2.left.parent = clone_2; clone_2.right = cloneEntityName(node.right); @@ -6595,7 +6751,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 142 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 144 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -6624,10 +6780,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 143 /* GetAccessor */) { + if (accessor.kind === 145 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 144 /* SetAccessor */) { + else if (accessor.kind === 146 /* SetAccessor */) { setAccessor = accessor; } else { @@ -6636,7 +6792,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */) + if ((member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -6647,10 +6803,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 143 /* GetAccessor */ && !getAccessor) { + if (member.kind === 145 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 144 /* SetAccessor */ && !setAccessor) { + if (member.kind === 146 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6783,16 +6939,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 111 /* StaticKeyword */: return 128 /* Static */; - case 110 /* PublicKeyword */: return 16 /* Public */; - case 109 /* ProtectedKeyword */: return 64 /* Protected */; - case 108 /* PrivateKeyword */: return 32 /* Private */; - case 113 /* AbstractKeyword */: return 256 /* Abstract */; - case 80 /* ExportKeyword */: return 1 /* Export */; - case 120 /* DeclareKeyword */: return 2 /* Ambient */; - case 72 /* ConstKeyword */: return 32768 /* Const */; - case 75 /* DefaultKeyword */: return 1024 /* Default */; - case 116 /* AsyncKeyword */: return 512 /* Async */; + case 113 /* StaticKeyword */: return 128 /* Static */; + case 112 /* PublicKeyword */: return 16 /* Public */; + case 111 /* ProtectedKeyword */: return 64 /* Protected */; + case 110 /* PrivateKeyword */: return 32 /* Private */; + case 115 /* AbstractKeyword */: return 256 /* Abstract */; + case 82 /* ExportKeyword */: return 1 /* Export */; + case 122 /* DeclareKeyword */: return 2 /* Ambient */; + case 74 /* ConstKeyword */: return 32768 /* Const */; + case 77 /* DefaultKeyword */: return 1024 /* Default */; + case 118 /* AsyncKeyword */: return 512 /* Async */; } return 0; } @@ -6800,29 +6956,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: - case 167 /* NewExpression */: - case 166 /* CallExpression */: - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - case 168 /* TaggedTemplateExpression */: - case 162 /* ArrayLiteralExpression */: - case 170 /* ParenthesizedExpression */: - case 163 /* ObjectLiteralExpression */: - case 184 /* ClassExpression */: - case 171 /* FunctionExpression */: - case 67 /* Identifier */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 169 /* NewExpression */: + case 168 /* CallExpression */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 170 /* TaggedTemplateExpression */: + case 164 /* ArrayLiteralExpression */: + case 172 /* ParenthesizedExpression */: + case 165 /* ObjectLiteralExpression */: + case 186 /* ClassExpression */: + case 173 /* FunctionExpression */: + case 69 /* Identifier */: case 10 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 11 /* NoSubstitutionTemplateLiteral */: - case 181 /* TemplateExpression */: - case 82 /* FalseKeyword */: - case 91 /* NullKeyword */: - case 95 /* ThisKeyword */: - case 97 /* TrueKeyword */: - case 93 /* SuperKeyword */: + case 183 /* TemplateExpression */: + case 84 /* FalseKeyword */: + case 93 /* NullKeyword */: + case 97 /* ThisKeyword */: + case 99 /* TrueKeyword */: + case 95 /* SuperKeyword */: return true; } } @@ -6830,12 +6986,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 55 /* FirstAssignment */ && token <= 66 /* LastAssignment */; + return token >= 56 /* FirstAssignment */ && token <= 68 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 186 /* ExpressionWithTypeArguments */ && - node.parent.token === 81 /* ExtendsKeyword */ && + return node.kind === 188 /* ExpressionWithTypeArguments */ && + node.parent.token === 83 /* ExtendsKeyword */ && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -6846,10 +7002,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 67 /* Identifier */) { + if (node.kind === 69 /* Identifier */) { return true; } - else if (node.kind === 164 /* PropertyAccessExpression */) { + else if (isPropertyAccessExpression(node)) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -6857,16 +7013,16 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 163 /* ObjectLiteralExpression */) { + if (kind === 165 /* ObjectLiteralExpression */) { return expression.properties.length === 0; } - if (kind === 162 /* ArrayLiteralExpression */) { + if (kind === 164 /* ArrayLiteralExpression */) { return expression.elements.length === 0; } return false; @@ -6876,12 +7032,12 @@ var ts; return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function isJavaScript(fileName) { - return ts.fileExtensionIs(fileName, ".js"); + function hasJavaScriptFileExtension(fileName) { + return ts.fileExtensionIs(fileName, ".js") || ts.fileExtensionIs(fileName, ".jsx"); } - ts.isJavaScript = isJavaScript; + ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; function isTsx(fileName) { - return ts.fileExtensionIs(fileName, ".tsx"); + return ts.fileExtensionIs(fileName, ".tsx") || ts.fileExtensionIs(fileName, ".jsx"); } ts.isTsx = isTsx; /** @@ -7178,9 +7334,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 135 /* TypeParameter */) { + if (d && d.kind === 137 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 215 /* InterfaceDeclaration */) { return current; } } @@ -7192,7 +7348,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(270 /* Count */); + var nodeConstructors = new Array(272 /* Count */); /* @internal */ ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -7237,20 +7393,26 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 133 /* QualifiedName */: + case 135 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 135 /* TypeParameter */: + case 137 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 136 /* Parameter */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 243 /* PropertyAssignment */: - case 244 /* ShorthandPropertyAssignment */: - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: + case 246 /* ShorthandPropertyAssignment */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.equalsToken) || + visitNode(cbNode, node.objectAssignmentInitializer); + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 245 /* PropertyAssignment */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -7259,24 +7421,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 171 /* FunctionExpression */: - case 211 /* FunctionDeclaration */: - case 172 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -7287,290 +7449,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 149 /* TypeReference */: + case 151 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 148 /* TypePredicate */: + case 150 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 153 /* TypeLiteral */: + case 155 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 154 /* ArrayType */: + case 156 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 155 /* TupleType */: + case 157 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 156 /* UnionType */: - case 157 /* IntersectionType */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 158 /* ParenthesizedType */: + case 160 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 159 /* ObjectBindingPattern */: - case 160 /* ArrayBindingPattern */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 164 /* PropertyAccessExpression */: + case 166 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 165 /* ElementAccessExpression */: + case 167 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 168 /* TaggedTemplateExpression */: + case 170 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 169 /* TypeAssertionExpression */: + case 171 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 173 /* DeleteExpression */: + case 175 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 174 /* TypeOfExpression */: + case 176 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 175 /* VoidExpression */: + case 177 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 182 /* YieldExpression */: + case 184 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 176 /* AwaitExpression */: + case 178 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 178 /* PostfixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 187 /* AsExpression */: + case 189 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 183 /* SpreadElementExpression */: + case 185 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 190 /* Block */: - case 217 /* ModuleBlock */: + case 192 /* Block */: + case 219 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 246 /* SourceFile */: + case 248 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 210 /* VariableDeclarationList */: + case 212 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 193 /* ExpressionStatement */: + case 195 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 194 /* IfStatement */: + case 196 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 195 /* DoStatement */: + case 197 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 196 /* WhileStatement */: + case 198 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 197 /* ForStatement */: + case 199 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 198 /* ForInStatement */: + case 200 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 199 /* ForOfStatement */: + case 201 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 200 /* ContinueStatement */: - case 201 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: return visitNode(cbNode, node.label); - case 202 /* ReturnStatement */: + case 204 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 203 /* WithStatement */: + case 205 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 204 /* SwitchStatement */: + case 206 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 218 /* CaseBlock */: + case 220 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 239 /* CaseClause */: + case 241 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 240 /* DefaultClause */: + case 242 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 206 /* ThrowStatement */: + case 208 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 207 /* TryStatement */: + case 209 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 137 /* Decorator */: + case 139 /* Decorator */: return visitNode(cbNode, node.expression); - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: 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 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: 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 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 245 /* EnumMember */: + case 247 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 221 /* ImportClause */: + case 223 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 222 /* NamespaceImport */: + case 224 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 223 /* NamedImports */: - case 227 /* NamedExports */: + case 225 /* NamedImports */: + case 229 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 224 /* ImportSpecifier */: - case 228 /* ExportSpecifier */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 181 /* TemplateExpression */: + case 183 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 188 /* TemplateSpan */: + case 190 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 241 /* HeritageClause */: + case 243 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 230 /* ExternalModuleReference */: + case 232 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 229 /* MissingDeclaration */: + case 231 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 231 /* JsxElement */: + case 233 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 232 /* JsxSelfClosingElement */: - case 233 /* JsxOpeningElement */: + case 234 /* JsxSelfClosingElement */: + case 235 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 236 /* JsxAttribute */: + case 238 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 237 /* JsxSpreadAttribute */: + case 239 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 238 /* JsxExpression */: + case 240 /* JsxExpression */: return visitNode(cbNode, node.expression); - case 235 /* JsxClosingElement */: + case 237 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 247 /* JSDocTypeExpression */: + case 249 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 251 /* JSDocUnionType */: + case 253 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 252 /* JSDocTupleType */: + case 254 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 250 /* JSDocArrayType */: + case 252 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 254 /* JSDocNonNullableType */: + case 256 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 253 /* JSDocNullableType */: + case 255 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 255 /* JSDocRecordType */: + case 257 /* JSDocRecordType */: return visitNodes(cbNodes, node.members); - case 257 /* JSDocTypeReference */: + case 259 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 258 /* JSDocOptionalType */: + case 260 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 259 /* JSDocFunctionType */: + case 261 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 260 /* JSDocVariadicType */: + case 262 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 261 /* JSDocConstructorType */: + case 263 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 262 /* JSDocThisType */: + case 264 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 256 /* JSDocRecordMember */: + case 258 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 263 /* JSDocComment */: + case 265 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 265 /* JSDocParameterTag */: + case 267 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 266 /* JSDocReturnTag */: + case 268 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 267 /* JSDocTypeTag */: + case 269 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 268 /* JSDocTemplateTag */: + case 270 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); } } @@ -7701,13 +7863,14 @@ var ts; // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes) { - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); + var isJavaScriptFile = ts.hasJavaScriptFileExtension(fileName) || _sourceText.lastIndexOf("// @language=javascript", 0) === 0; + initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor); var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); clearState(); return result; } Parser.parseSourceFile = parseSourceFile; - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor) { + function initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor) { sourceText = _sourceText; syntaxCursor = _syntaxCursor; parseDiagnostics = []; @@ -7715,7 +7878,7 @@ var ts; identifiers = {}; identifierCount = 0; nodeCount = 0; - contextFlags = ts.isJavaScript(fileName) ? 32 /* JavaScriptFile */ : 0 /* None */; + contextFlags = isJavaScriptFile ? 32 /* JavaScriptFile */ : 0 /* None */; parseErrorBeforeNextFinishedNode = false; // Initialize and prime the scanner before parsing the source elements. scanner.setText(sourceText); @@ -7736,6 +7899,9 @@ var ts; } function parseSourceFileWorker(fileName, languageVersion, setParentNodes) { sourceFile = createSourceFile(fileName, languageVersion); + if (contextFlags & 32 /* JavaScriptFile */) { + sourceFile.parserContextFlags = 32 /* JavaScriptFile */; + } // Prime the scanner. token = nextToken(); processReferenceComments(sourceFile); @@ -7753,7 +7919,7 @@ var ts; // If this is a javascript file, proactively see if we can get JSDoc comments for // relevant nodes in the file. We'll use these to provide typing informaion if they're // available. - if (ts.isJavaScript(fileName)) { + if (ts.isSourceFileJavaScript(sourceFile)) { addJSDocComments(); } return sourceFile; @@ -7765,9 +7931,9 @@ var ts; // Add additional cases as necessary depending on how we see JSDoc comments used // in the wild. switch (node.kind) { - case 191 /* VariableStatement */: - case 211 /* FunctionDeclaration */: - case 136 /* Parameter */: + case 193 /* VariableStatement */: + case 213 /* FunctionDeclaration */: + case 138 /* Parameter */: addJSDocComment(node); } forEachChild(node, visit); @@ -7808,7 +7974,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(246 /* SourceFile */, /*pos*/ 0); + var sourceFile = createNode(248 /* SourceFile */, /*pos*/ 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -7972,7 +8138,7 @@ var ts; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; // Note: it is not actually necessary to save/restore the context flags here. That's - // because the saving/restorating of these flags happens naturally through the recursive + // because the saving/restoring of these flags happens naturally through the recursive // descent nature of our parser. However, we still store this here just so we can // assert that that invariant holds. var saveContextFlags = contextFlags; @@ -8007,20 +8173,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token === 67 /* Identifier */) { + if (token === 69 /* Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token === 112 /* YieldKeyword */ && inYieldContext()) { + if (token === 114 /* YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token === 117 /* AwaitKeyword */ && inAwaitContext()) { + if (token === 119 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token > 103 /* LastReservedWord */; + return token > 105 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -8126,16 +8292,16 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(67 /* Identifier */); + var node = createNode(69 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token !== 67 /* Identifier */) { + if (token !== 69 /* Identifier */) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -8170,7 +8336,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(134 /* ComputedPropertyName */); + var node = createNode(136 /* ComputedPropertyName */); parseExpected(19 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -8183,21 +8349,28 @@ var ts; return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 72 /* ConstKeyword */) { + if (token === 74 /* ConstKeyword */) { // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 79 /* EnumKeyword */; + return nextToken() === 81 /* EnumKeyword */; } - if (token === 80 /* ExportKeyword */) { + if (token === 82 /* ExportKeyword */) { nextToken(); - if (token === 75 /* DefaultKeyword */) { + if (token === 77 /* DefaultKeyword */) { return lookAhead(nextTokenIsClassOrFunction); } return token !== 37 /* AsteriskToken */ && token !== 15 /* OpenBraceToken */ && canFollowModifier(); } - if (token === 75 /* DefaultKeyword */) { + if (token === 77 /* DefaultKeyword */) { return nextTokenIsClassOrFunction(); } + if (token === 113 /* StaticKeyword */) { + nextToken(); + return canFollowModifier(); + } nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return false; + } return canFollowModifier(); } function parseAnyContextualModifier() { @@ -8211,7 +8384,7 @@ var ts; } function nextTokenIsClassOrFunction() { nextToken(); - return token === 71 /* ClassKeyword */ || token === 85 /* FunctionKeyword */; + return token === 73 /* ClassKeyword */ || token === 87 /* FunctionKeyword */; } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -8231,7 +8404,7 @@ var ts; // outer module. We just want to consume and move on. return !(token === 23 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */; + return token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */; case 4 /* TypeMembers */: return isStartOfTypeMember(); case 5 /* ClassMembers */: @@ -8305,7 +8478,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 81 /* ExtendsKeyword */ || next === 104 /* ImplementsKeyword */; + return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 83 /* ExtendsKeyword */ || next === 106 /* ImplementsKeyword */; } return true; } @@ -8318,8 +8491,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 104 /* ImplementsKeyword */ || - token === 81 /* ExtendsKeyword */) { + if (token === 106 /* ImplementsKeyword */ || + token === 83 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -8345,14 +8518,14 @@ var ts; case 21 /* ImportOrExportSpecifiers */: return token === 16 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token === 16 /* CloseBraceToken */ || token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */; + return token === 16 /* CloseBraceToken */ || token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token === 15 /* OpenBraceToken */ || token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; + return token === 15 /* OpenBraceToken */ || token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 17 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */ || token === 15 /* OpenBraceToken */ || token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; + return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */ || token === 15 /* OpenBraceToken */ || token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token === 18 /* CloseParenToken */ || token === 23 /* SemicolonToken */; @@ -8369,11 +8542,11 @@ var ts; case 20 /* HeritageClauses */: return token === 15 /* OpenBraceToken */ || token === 16 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token === 27 /* GreaterThanToken */ || token === 38 /* SlashToken */; + return token === 27 /* GreaterThanToken */ || token === 39 /* SlashToken */; case 14 /* JsxChildren */: return token === 25 /* LessThanToken */ && lookAhead(nextTokenIsSlash); case 22 /* JSDocFunctionParameters */: - return token === 18 /* CloseParenToken */ || token === 53 /* ColonToken */ || token === 16 /* CloseBraceToken */; + return token === 18 /* CloseParenToken */ || token === 54 /* ColonToken */ || token === 16 /* CloseBraceToken */; case 23 /* JSDocTypeArguments */: return token === 27 /* GreaterThanToken */ || token === 16 /* CloseBraceToken */; case 25 /* JSDocTupleTypes */: @@ -8561,20 +8734,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 142 /* Constructor */: - case 147 /* IndexSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 139 /* PropertyDeclaration */: - case 189 /* SemicolonClassElement */: + case 144 /* Constructor */: + case 149 /* IndexSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 191 /* SemicolonClassElement */: return true; - case 141 /* MethodDeclaration */: + case 143 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 67 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 119 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 69 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 121 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -8583,8 +8756,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 239 /* CaseClause */: - case 240 /* DefaultClause */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: return true; } } @@ -8593,58 +8766,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 211 /* FunctionDeclaration */: - case 191 /* VariableStatement */: - case 190 /* Block */: - case 194 /* IfStatement */: - case 193 /* ExpressionStatement */: - case 206 /* ThrowStatement */: - case 202 /* ReturnStatement */: - case 204 /* SwitchStatement */: - case 201 /* BreakStatement */: - case 200 /* ContinueStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 197 /* ForStatement */: - case 196 /* WhileStatement */: - case 203 /* WithStatement */: - case 192 /* EmptyStatement */: - case 207 /* TryStatement */: - case 205 /* LabeledStatement */: - case 195 /* DoStatement */: - case 208 /* DebuggerStatement */: - case 220 /* ImportDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 226 /* ExportDeclaration */: - case 225 /* ExportAssignment */: - case 216 /* ModuleDeclaration */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 214 /* TypeAliasDeclaration */: + case 213 /* FunctionDeclaration */: + case 193 /* VariableStatement */: + case 192 /* Block */: + case 196 /* IfStatement */: + case 195 /* ExpressionStatement */: + case 208 /* ThrowStatement */: + case 204 /* ReturnStatement */: + case 206 /* SwitchStatement */: + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 199 /* ForStatement */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 194 /* EmptyStatement */: + case 209 /* TryStatement */: + case 207 /* LabeledStatement */: + case 197 /* DoStatement */: + case 210 /* DebuggerStatement */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 228 /* ExportDeclaration */: + case 227 /* ExportAssignment */: + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 216 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 245 /* EnumMember */; + return node.kind === 247 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 146 /* ConstructSignature */: - case 140 /* MethodSignature */: - case 147 /* IndexSignature */: - case 138 /* PropertySignature */: - case 145 /* CallSignature */: + case 148 /* ConstructSignature */: + case 142 /* MethodSignature */: + case 149 /* IndexSignature */: + case 140 /* PropertySignature */: + case 147 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 209 /* VariableDeclaration */) { + if (node.kind !== 211 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -8665,7 +8838,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 136 /* Parameter */) { + if (node.kind !== 138 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -8782,7 +8955,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(21 /* DotToken */)) { - var node = createNode(133 /* QualifiedName */, entity.pos); + var node = createNode(135 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -8815,13 +8988,13 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(67 /* Identifier */, /*reportAtCurrentToken*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(69 /* Identifier */, /*reportAtCurrentToken*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(181 /* TemplateExpression */); + var template = createNode(183 /* TemplateExpression */); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; @@ -8834,7 +9007,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(188 /* TemplateSpan */); + var span = createNode(190 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token === 16 /* CloseBraceToken */) { @@ -8876,14 +9049,14 @@ var ts; // TYPES function parseTypeReferenceOrTypePredicate() { var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - if (typeName.kind === 67 /* Identifier */ && token === 122 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (typeName.kind === 69 /* Identifier */ && token === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(148 /* TypePredicate */, typeName.pos); + var node_1 = createNode(150 /* TypePredicate */, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(149 /* TypeReference */, typeName.pos); + var node = createNode(151 /* TypeReference */, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 25 /* LessThanToken */) { node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); @@ -8891,15 +9064,15 @@ var ts; return finishNode(node); } function parseTypeQuery() { - var node = createNode(152 /* TypeQuery */); - parseExpected(99 /* TypeOfKeyword */); + var node = createNode(154 /* TypeQuery */); + parseExpected(101 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(135 /* TypeParameter */); + var node = createNode(137 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(81 /* ExtendsKeyword */)) { + if (parseOptional(83 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -8926,7 +9099,7 @@ var ts; } } function parseParameterType() { - if (parseOptional(53 /* ColonToken */)) { + if (parseOptional(54 /* ColonToken */)) { return token === 9 /* StringLiteral */ ? parseLiteralNode(/*internName*/ true) : parseType(); @@ -8934,7 +9107,7 @@ var ts; return undefined; } function isStartOfParameter() { - return token === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 54 /* AtToken */; + return token === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 55 /* AtToken */; } function setModifiers(node, modifiers) { if (modifiers) { @@ -8943,7 +9116,7 @@ var ts; } } function parseParameter() { - var node = createNode(136 /* Parameter */); + var node = createNode(138 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); @@ -8961,7 +9134,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(52 /* QuestionToken */); + node.questionToken = parseOptionalToken(53 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(/*inParameter*/ true); // Do not check for initializers in an ambient context for parameters. This is not @@ -9037,10 +9210,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 146 /* ConstructSignature */) { - parseExpected(90 /* NewKeyword */); + if (kind === 148 /* ConstructSignature */) { + parseExpected(92 /* NewKeyword */); } - fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -9087,21 +9260,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token === 53 /* ColonToken */ || token === 24 /* CommaToken */) { + if (token === 54 /* ColonToken */ || token === 24 /* CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token !== 52 /* QuestionToken */) { + if (token !== 53 /* QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token === 53 /* ColonToken */ || token === 24 /* CommaToken */ || token === 20 /* CloseBracketToken */; + return token === 54 /* ColonToken */ || token === 24 /* CommaToken */ || token === 20 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(147 /* IndexSignature */, fullStart); + var node = createNode(149 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); @@ -9112,19 +9285,19 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(52 /* QuestionToken */); + var questionToken = parseOptionalToken(53 /* QuestionToken */); if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { - var method = createNode(140 /* MethodSignature */, fullStart); + var method = createNode(142 /* MethodSignature */, fullStart); method.name = name; method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(138 /* PropertySignature */, fullStart); + var property = createNode(140 /* PropertySignature */, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -9158,23 +9331,23 @@ var ts; nextToken(); return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */ || - token === 52 /* QuestionToken */ || - token === 53 /* ColonToken */ || + token === 53 /* QuestionToken */ || + token === 54 /* ColonToken */ || canParseSemicolon(); } function parseTypeMember() { switch (token) { case 17 /* OpenParenToken */: case 25 /* LessThanToken */: - return parseSignatureMember(145 /* CallSignature */); + return parseSignatureMember(147 /* CallSignature */); case 19 /* OpenBracketToken */: // Indexer or computed property return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined) : parsePropertyOrMethodSignature(); - case 90 /* NewKeyword */: + case 92 /* NewKeyword */: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(146 /* ConstructSignature */); + return parseSignatureMember(148 /* ConstructSignature */); } // fall through. case 9 /* StringLiteral */: @@ -9211,7 +9384,7 @@ var ts; return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(153 /* TypeLiteral */); + var node = createNode(155 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -9227,12 +9400,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(155 /* TupleType */); + var node = createNode(157 /* TupleType */); node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(158 /* ParenthesizedType */); + var node = createNode(160 /* ParenthesizedType */); parseExpected(17 /* OpenParenToken */); node.type = parseType(); parseExpected(18 /* CloseParenToken */); @@ -9240,8 +9413,8 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 151 /* ConstructorType */) { - parseExpected(90 /* NewKeyword */); + if (kind === 153 /* ConstructorType */) { + parseExpected(92 /* NewKeyword */); } fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); return finishNode(node); @@ -9252,17 +9425,18 @@ var ts; } function parseNonArrayType() { switch (token) { - case 115 /* AnyKeyword */: - case 128 /* StringKeyword */: - case 126 /* NumberKeyword */: - case 118 /* BooleanKeyword */: - case 129 /* SymbolKeyword */: + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 101 /* VoidKeyword */: + case 103 /* VoidKeyword */: + case 97 /* ThisKeyword */: return parseTokenNode(); - case 99 /* TypeOfKeyword */: + case 101 /* TypeOfKeyword */: return parseTypeQuery(); case 15 /* OpenBraceToken */: return parseTypeLiteral(); @@ -9276,17 +9450,18 @@ var ts; } function isStartOfType() { switch (token) { - case 115 /* AnyKeyword */: - case 128 /* StringKeyword */: - case 126 /* NumberKeyword */: - case 118 /* BooleanKeyword */: - case 129 /* SymbolKeyword */: - case 101 /* VoidKeyword */: - case 99 /* TypeOfKeyword */: + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: + case 97 /* ThisKeyword */: + case 101 /* TypeOfKeyword */: case 15 /* OpenBraceToken */: case 19 /* OpenBracketToken */: case 25 /* LessThanToken */: - case 90 /* NewKeyword */: + case 92 /* NewKeyword */: return true; case 17 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, @@ -9304,7 +9479,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { parseExpected(20 /* CloseBracketToken */); - var node = createNode(154 /* ArrayType */, type.pos); + var node = createNode(156 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -9326,10 +9501,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(157 /* IntersectionType */, parseArrayTypeOrHigher, 45 /* AmpersandToken */); + return parseUnionOrIntersectionType(159 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(156 /* UnionType */, parseIntersectionTypeOrHigher, 46 /* BarToken */); + return parseUnionOrIntersectionType(158 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */); } function isStartOfFunctionType() { if (token === 25 /* LessThanToken */) { @@ -9346,8 +9521,8 @@ var ts; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 53 /* ColonToken */ || token === 24 /* CommaToken */ || - token === 52 /* QuestionToken */ || token === 55 /* EqualsToken */ || + if (token === 54 /* ColonToken */ || token === 24 /* CommaToken */ || + token === 53 /* QuestionToken */ || token === 56 /* EqualsToken */ || isIdentifier() || ts.isModifier(token)) { // ( id : // ( id , @@ -9373,24 +9548,24 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(150 /* FunctionType */); + return parseFunctionOrConstructorType(152 /* FunctionType */); } - if (token === 90 /* NewKeyword */) { - return parseFunctionOrConstructorType(151 /* ConstructorType */); + if (token === 92 /* NewKeyword */) { + return parseFunctionOrConstructorType(153 /* ConstructorType */); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(53 /* ColonToken */) ? parseType() : undefined; + return parseOptional(54 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token) { - case 95 /* ThisKeyword */: - case 93 /* SuperKeyword */: - case 91 /* NullKeyword */: - case 97 /* TrueKeyword */: - case 82 /* FalseKeyword */: + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: + case 93 /* NullKeyword */: + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 11 /* NoSubstitutionTemplateLiteral */: @@ -9398,12 +9573,12 @@ var ts; case 17 /* OpenParenToken */: case 19 /* OpenBracketToken */: case 15 /* OpenBraceToken */: - case 85 /* FunctionKeyword */: - case 71 /* ClassKeyword */: - case 90 /* NewKeyword */: - case 38 /* SlashToken */: - case 59 /* SlashEqualsToken */: - case 67 /* Identifier */: + case 87 /* FunctionKeyword */: + case 73 /* ClassKeyword */: + case 92 /* NewKeyword */: + case 39 /* SlashToken */: + case 61 /* SlashEqualsToken */: + case 69 /* Identifier */: return true; default: return isIdentifier(); @@ -9416,16 +9591,16 @@ var ts; switch (token) { case 35 /* PlusToken */: case 36 /* MinusToken */: - case 49 /* TildeToken */: - case 48 /* ExclamationToken */: - case 76 /* DeleteKeyword */: - case 99 /* TypeOfKeyword */: - case 101 /* VoidKeyword */: - case 40 /* PlusPlusToken */: - case 41 /* MinusMinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: + case 78 /* DeleteKeyword */: + case 101 /* TypeOfKeyword */: + case 103 /* VoidKeyword */: + case 41 /* PlusPlusToken */: + case 42 /* MinusMinusToken */: case 25 /* LessThanToken */: - case 117 /* AwaitKeyword */: - case 112 /* YieldKeyword */: + case 119 /* AwaitKeyword */: + case 114 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -9444,9 +9619,9 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token !== 15 /* OpenBraceToken */ && - token !== 85 /* FunctionKeyword */ && - token !== 71 /* ClassKeyword */ && - token !== 54 /* AtToken */ && + token !== 87 /* FunctionKeyword */ && + token !== 73 /* ClassKeyword */ && + token !== 55 /* AtToken */ && isStartOfExpression(); } function allowInAndParseExpression() { @@ -9472,7 +9647,7 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 55 /* EqualsToken */) { + if (token !== 56 /* EqualsToken */) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse // this as an equals-value clause with a missing equals. @@ -9489,7 +9664,7 @@ var ts; } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(55 /* EqualsToken */); + parseExpected(56 /* EqualsToken */); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -9527,7 +9702,7 @@ var ts; // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 67 /* Identifier */ && token === 34 /* EqualsGreaterThanToken */) { + if (expr.kind === 69 /* Identifier */ && token === 34 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -9543,7 +9718,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 112 /* YieldKeyword */) { + if (token === 114 /* YieldKeyword */) { // If we have a 'yield' keyword, and htis is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -9572,7 +9747,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(182 /* YieldExpression */); + var node = createNode(184 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -9592,8 +9767,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(172 /* ArrowFunction */, identifier.pos); - var parameter = createNode(136 /* Parameter */, identifier.pos); + var node = createNode(174 /* ArrowFunction */, identifier.pos); + var parameter = createNode(138 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -9635,7 +9810,7 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */ || token === 116 /* AsyncKeyword */) { + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */ || token === 118 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } if (token === 34 /* EqualsGreaterThanToken */) { @@ -9648,7 +9823,7 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 116 /* AsyncKeyword */) { + if (token === 118 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; @@ -9668,7 +9843,7 @@ var ts; var third = nextToken(); switch (third) { case 34 /* EqualsGreaterThanToken */: - case 53 /* ColonToken */: + case 54 /* ColonToken */: case 15 /* OpenBraceToken */: return 1 /* True */; default: @@ -9699,7 +9874,7 @@ var ts; } // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - if (nextToken() === 53 /* ColonToken */) { + if (nextToken() === 54 /* ColonToken */) { return 1 /* True */; } // This *could* be a parenthesized arrow function. @@ -9717,10 +9892,10 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 81 /* ExtendsKeyword */) { + if (third === 83 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 55 /* EqualsToken */: + case 56 /* EqualsToken */: case 27 /* GreaterThanToken */: return false; default: @@ -9745,7 +9920,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(172 /* ArrowFunction */); + var node = createNode(174 /* ArrowFunction */); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512 /* Async */); // Arrow functions are never generators. @@ -9755,7 +9930,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { return undefined; @@ -9779,8 +9954,8 @@ var ts; return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); } if (token !== 23 /* SemicolonToken */ && - token !== 85 /* FunctionKeyword */ && - token !== 71 /* ClassKeyword */ && + token !== 87 /* FunctionKeyword */ && + token !== 73 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -9805,17 +9980,17 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(52 /* QuestionToken */); + var questionToken = parseOptionalToken(53 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(180 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(182 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(53 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(53 /* ColonToken */)); + node.colonToken = parseExpectedToken(54 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(54 /* ColonToken */)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -9824,7 +9999,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 88 /* InKeyword */ || t === 132 /* OfKeyword */; + return t === 90 /* InKeyword */ || t === 134 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -9833,13 +10008,36 @@ var ts; reScanGreaterToken(); var newPrecedence = getBinaryOperatorPrecedence(); // Check the precedence to see if we should "take" this operator - if (newPrecedence <= precedence) { + // - For left associative operator (all operator but **), consume the operator, + // recursively call the function below, and parse binaryExpression as a rightOperand + // of the caller if the new precendence of the operator is greater then or equal to the current precendence. + // For example: + // a - b - c; + // ^token; leftOperand = b. Return b to the caller as a rightOperand + // a * b - c + // ^token; leftOperand = b. Return b to the caller as a rightOperand + // a - b * c; + // ^token; leftOperand = b. Return b * c to the caller as a rightOperand + // - For right associative operator (**), consume the operator, recursively call the function + // and parse binaryExpression as a rightOperand of the caller if the new precendence of + // the operator is strictly grater than the current precendence + // For example: + // a ** b ** c; + // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand + // a - b ** c; + // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand + // a ** b - c + // ^token; leftOperand = b. Return b to the caller as a rightOperand + var consumeCurrentOperator = token === 38 /* AsteriskAsteriskToken */ ? + newPrecedence >= precedence : + newPrecedence > precedence; + if (!consumeCurrentOperator) { break; } - if (token === 88 /* InKeyword */ && inDisallowInContext()) { + if (token === 90 /* InKeyword */ && inDisallowInContext()) { break; } - if (token === 114 /* AsKeyword */) { + if (token === 116 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -9860,22 +10058,22 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 88 /* InKeyword */) { + if (inDisallowInContext() && token === 90 /* InKeyword */) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 51 /* BarBarToken */: + case 52 /* BarBarToken */: return 1; - case 50 /* AmpersandAmpersandToken */: + case 51 /* AmpersandAmpersandToken */: return 2; - case 46 /* BarToken */: + case 47 /* BarToken */: return 3; - case 47 /* CaretToken */: + case 48 /* CaretToken */: return 4; - case 45 /* AmpersandToken */: + case 46 /* AmpersandToken */: return 5; case 30 /* EqualsEqualsToken */: case 31 /* ExclamationEqualsToken */: @@ -9886,66 +10084,68 @@ var ts; case 27 /* GreaterThanToken */: case 28 /* LessThanEqualsToken */: case 29 /* GreaterThanEqualsToken */: - case 89 /* InstanceOfKeyword */: - case 88 /* InKeyword */: - case 114 /* AsKeyword */: + case 91 /* InstanceOfKeyword */: + case 90 /* InKeyword */: + case 116 /* AsKeyword */: return 7; - case 42 /* LessThanLessThanToken */: - case 43 /* GreaterThanGreaterThanToken */: - case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 43 /* LessThanLessThanToken */: + case 44 /* GreaterThanGreaterThanToken */: + case 45 /* GreaterThanGreaterThanGreaterThanToken */: return 8; case 35 /* PlusToken */: case 36 /* MinusToken */: return 9; case 37 /* AsteriskToken */: - case 38 /* SlashToken */: - case 39 /* PercentToken */: + case 39 /* SlashToken */: + case 40 /* PercentToken */: return 10; + case 38 /* AsteriskAsteriskToken */: + return 11; } // -1 is lower than all other precedences. Returning it will cause binary expression // parsing to stop. return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(179 /* BinaryExpression */, left.pos); + var node = createNode(181 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(187 /* AsExpression */, left.pos); + var node = createNode(189 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(177 /* PrefixUnaryExpression */); + var node = createNode(179 /* PrefixUnaryExpression */); node.operator = token; nextToken(); - node.operand = parseUnaryExpressionOrHigher(); + node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(173 /* DeleteExpression */); + var node = createNode(175 /* DeleteExpression */); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(174 /* TypeOfExpression */); + var node = createNode(176 /* TypeOfExpression */); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(175 /* VoidExpression */); + var node = createNode(177 /* VoidExpression */); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token === 117 /* AwaitKeyword */) { + if (token === 119 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -9955,46 +10155,137 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(176 /* AwaitExpression */); + var node = createNode(178 /* AwaitExpression */); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + /** + * Parse ES7 unary expression and await expression + * + * ES7 UnaryExpression: + * 1) SimpleUnaryExpression[?yield] + * 2) IncrementExpression[?yield] ** UnaryExpression[?yield] + */ function parseUnaryExpressionOrHigher() { if (isAwaitExpression()) { return parseAwaitExpression(); } + if (isIncrementExpression()) { + var incrementExpression = parseIncrementExpression(); + return token === 38 /* AsteriskAsteriskToken */ ? + parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : + incrementExpression; + } + var unaryOperator = token; + var simpleUnaryExpression = parseSimpleUnaryExpression(); + if (token === 38 /* AsteriskAsteriskToken */) { + var diagnostic; + var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); + if (simpleUnaryExpression.kind === 171 /* TypeAssertionExpression */) { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); + } + else { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, ts.tokenToString(unaryOperator)); + } + } + return simpleUnaryExpression; + } + /** + * Parse ES7 simple-unary expression or higher: + * + * ES7 SimpleUnaryExpression: + * 1) IncrementExpression[?yield] + * 2) delete UnaryExpression[?yield] + * 3) void UnaryExpression[?yield] + * 4) typeof UnaryExpression[?yield] + * 5) + UnaryExpression[?yield] + * 6) - UnaryExpression[?yield] + * 7) ~ UnaryExpression[?yield] + * 8) ! UnaryExpression[?yield] + */ + function parseSimpleUnaryExpression() { switch (token) { case 35 /* PlusToken */: case 36 /* MinusToken */: - case 49 /* TildeToken */: - case 48 /* ExclamationToken */: - case 40 /* PlusPlusToken */: - case 41 /* MinusMinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 76 /* DeleteKeyword */: + case 78 /* DeleteKeyword */: return parseDeleteExpression(); - case 99 /* TypeOfKeyword */: + case 101 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 101 /* VoidKeyword */: + case 103 /* VoidKeyword */: return parseVoidExpression(); case 25 /* LessThanToken */: + // This is modified UnaryExpression grammar in TypeScript + // UnaryExpression (modified): + // < type > UnaryExpression + return parseTypeAssertion(); + default: + return parseIncrementExpression(); + } + } + /** + * Check if the current token can possibly be an ES7 increment expression. + * + * ES7 IncrementExpression: + * LeftHandSideExpression[?Yield] + * LeftHandSideExpression[?Yield][no LineTerminator here]++ + * LeftHandSideExpression[?Yield][no LineTerminator here]-- + * ++LeftHandSideExpression[?Yield] + * --LeftHandSideExpression[?Yield] + */ + function isIncrementExpression() { + // This function is called inside parseUnaryExpression to decide + // whether to call parseSimpleUnaryExpression or call parseIncrmentExpression directly + switch (token) { + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: + case 78 /* DeleteKeyword */: + case 101 /* TypeOfKeyword */: + case 103 /* VoidKeyword */: + return false; + case 25 /* LessThanToken */: + // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { - return parseTypeAssertion(); - } - if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); + return false; } + // We are in JSX context and the token is part of JSXElement. // Fall through default: - return parsePostfixExpressionOrHigher(); + return true; } } - function parsePostfixExpressionOrHigher() { + /** + * Parse ES7 IncrementExpression. IncrementExpression is used instead of ES6's PostFixExpression. + * + * ES7 IncrementExpression[yield]: + * 1) LeftHandSideExpression[?yield] + * 2) LeftHandSideExpression[?yield] [[no LineTerminator here]]++ + * 3) LeftHandSideExpression[?yield] [[no LineTerminator here]]-- + * 4) ++LeftHandSideExpression[?yield] + * 5) --LeftHandSideExpression[?yield] + * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression + */ + function parseIncrementExpression() { + if (token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) { + var node = createNode(179 /* PrefixUnaryExpression */); + node.operator = token; + nextToken(); + node.operand = parseLeftHandSideExpressionOrHigher(); + return finishNode(node); + } + else if (sourceFile.languageVariant === 1 /* JSX */ && token === 25 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeyword)) { + // JSXElement is part of primaryExpression + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); + } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 40 /* PlusPlusToken */ || token === 41 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(178 /* PostfixUnaryExpression */, expression.pos); + if ((token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(180 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -10033,7 +10324,7 @@ var ts; // the last two CallExpression productions. Or we have a MemberExpression which either // completes the LeftHandSideExpression, or starts the beginning of the first four // CallExpression productions. - var expression = token === 93 /* SuperKeyword */ + var expression = token === 95 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); // Now, we *may* be complete. However, we might have consumed the start of a @@ -10098,7 +10389,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(164 /* PropertyAccessExpression */, expression.pos); + var node = createNode(166 /* PropertyAccessExpression */, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -10106,27 +10397,27 @@ var ts; } function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); - if (opening.kind === 233 /* JsxOpeningElement */) { - var node = createNode(231 /* JsxElement */, opening.pos); + if (opening.kind === 235 /* JsxOpeningElement */) { + var node = createNode(233 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 232 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 234 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements return opening; } } function parseJsxText() { - var node = createNode(234 /* JsxText */, scanner.getStartPos()); + var node = createNode(236 /* JsxText */, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 234 /* JsxText */: + case 236 /* JsxText */: return parseJsxText(); case 15 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); @@ -10165,11 +10456,11 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(233 /* JsxOpeningElement */, fullStart); + node = createNode(235 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(38 /* SlashToken */); + parseExpected(39 /* SlashToken */); if (inExpressionContext) { parseExpected(27 /* GreaterThanToken */); } @@ -10177,7 +10468,7 @@ var ts; parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); scanJsxText(); } - node = createNode(232 /* JsxSelfClosingElement */, fullStart); + node = createNode(234 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -10188,7 +10479,7 @@ var ts; var elementName = parseIdentifierName(); while (parseOptional(21 /* DotToken */)) { scanJsxIdentifier(); - var node = createNode(133 /* QualifiedName */, elementName.pos); + var node = createNode(135 /* QualifiedName */, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); @@ -10196,7 +10487,7 @@ var ts; return elementName; } function parseJsxExpression(inExpressionContext) { - var node = createNode(238 /* JsxExpression */); + var node = createNode(240 /* JsxExpression */); parseExpected(15 /* OpenBraceToken */); if (token !== 16 /* CloseBraceToken */) { node.expression = parseExpression(); @@ -10215,9 +10506,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(236 /* JsxAttribute */); + var node = createNode(238 /* JsxAttribute */); node.name = parseIdentifierName(); - if (parseOptional(55 /* EqualsToken */)) { + if (parseOptional(56 /* EqualsToken */)) { switch (token) { case 9 /* StringLiteral */: node.initializer = parseLiteralNode(); @@ -10230,7 +10521,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(237 /* JsxSpreadAttribute */); + var node = createNode(239 /* JsxSpreadAttribute */); parseExpected(15 /* OpenBraceToken */); parseExpected(22 /* DotDotDotToken */); node.expression = parseExpression(); @@ -10238,7 +10529,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(235 /* JsxClosingElement */); + var node = createNode(237 /* JsxClosingElement */); parseExpected(26 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -10251,18 +10542,18 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(169 /* TypeAssertionExpression */); + var node = createNode(171 /* TypeAssertionExpression */); parseExpected(25 /* LessThanToken */); node.type = parseType(); parseExpected(27 /* GreaterThanToken */); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { var dotToken = parseOptionalToken(21 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(164 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(166 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -10271,7 +10562,7 @@ var ts; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(19 /* OpenBracketToken */)) { - var indexedAccess = createNode(165 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(167 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". // Check for that common pattern and report a better error message. @@ -10287,7 +10578,7 @@ var ts; continue; } if (token === 11 /* NoSubstitutionTemplateLiteral */ || token === 12 /* TemplateHead */) { - var tagExpression = createNode(168 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(170 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 11 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -10310,7 +10601,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(166 /* CallExpression */, expression.pos); + var callExpr = createNode(168 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -10318,7 +10609,7 @@ var ts; continue; } else if (token === 17 /* OpenParenToken */) { - var callExpr = createNode(166 /* CallExpression */, expression.pos); + var callExpr = createNode(168 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -10356,18 +10647,18 @@ var ts; case 21 /* DotToken */: // foo. case 18 /* CloseParenToken */: // foo) case 20 /* CloseBracketToken */: // foo] - case 53 /* ColonToken */: // foo: + case 54 /* ColonToken */: // foo: case 23 /* SemicolonToken */: // foo; - case 52 /* QuestionToken */: // foo? + case 53 /* QuestionToken */: // foo? case 30 /* EqualsEqualsToken */: // foo == case 32 /* EqualsEqualsEqualsToken */: // foo === case 31 /* ExclamationEqualsToken */: // foo != case 33 /* ExclamationEqualsEqualsToken */: // foo !== - case 50 /* AmpersandAmpersandToken */: // foo && - case 51 /* BarBarToken */: // foo || - case 47 /* CaretToken */: // foo ^ - case 45 /* AmpersandToken */: // foo & - case 46 /* BarToken */: // foo | + case 51 /* AmpersandAmpersandToken */: // foo && + case 52 /* BarBarToken */: // foo || + case 48 /* CaretToken */: // foo ^ + case 46 /* AmpersandToken */: // foo & + case 47 /* BarToken */: // foo | case 16 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal @@ -10390,11 +10681,11 @@ var ts; case 9 /* StringLiteral */: case 11 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 95 /* ThisKeyword */: - case 93 /* SuperKeyword */: - case 91 /* NullKeyword */: - case 97 /* TrueKeyword */: - case 82 /* FalseKeyword */: + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: + case 93 /* NullKeyword */: + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: return parseTokenNode(); case 17 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -10402,7 +10693,7 @@ var ts; return parseArrayLiteralExpression(); case 15 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 116 /* AsyncKeyword */: + case 118 /* AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -10410,14 +10701,14 @@ var ts; break; } return parseFunctionExpression(); - case 71 /* ClassKeyword */: + case 73 /* ClassKeyword */: return parseClassExpression(); - case 85 /* FunctionKeyword */: + case 87 /* FunctionKeyword */: return parseFunctionExpression(); - case 90 /* NewKeyword */: + case 92 /* NewKeyword */: return parseNewExpression(); - case 38 /* SlashToken */: - case 59 /* SlashEqualsToken */: + case 39 /* SlashToken */: + case 61 /* SlashEqualsToken */: if (reScanSlashToken() === 10 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -10428,28 +10719,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(170 /* ParenthesizedExpression */); + var node = createNode(172 /* ParenthesizedExpression */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(183 /* SpreadElementExpression */); + var node = createNode(185 /* SpreadElementExpression */); parseExpected(22 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 22 /* DotDotDotToken */ ? parseSpreadElement() : - token === 24 /* CommaToken */ ? createNode(185 /* OmittedExpression */) : + token === 24 /* CommaToken */ ? createNode(187 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(162 /* ArrayLiteralExpression */); + var node = createNode(164 /* ArrayLiteralExpression */); parseExpected(19 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048 /* MultiLine */; @@ -10458,11 +10749,11 @@ var ts; return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(121 /* GetKeyword */)) { - return parseAccessorDeclaration(143 /* GetAccessor */, fullStart, decorators, modifiers); + if (parseContextualModifier(123 /* GetKeyword */)) { + return parseAccessorDeclaration(145 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(127 /* SetKeyword */)) { - return parseAccessorDeclaration(144 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(129 /* SetKeyword */)) { + return parseAccessorDeclaration(146 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -10479,28 +10770,38 @@ var ts; var nameToken = token; var propertyName = parsePropertyName(); // Disallowing of optional property assignments happens in the grammar checker. - var questionToken = parseOptionalToken(52 /* QuestionToken */); + var questionToken = parseOptionalToken(53 /* QuestionToken */); if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - // Parse to check if it is short-hand property assignment or normal property assignment - if ((token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(244 /* ShorthandPropertyAssignment */, fullStart); + // check if it is short-hand property assignment or normal property assignment + // NOTE: if token is EqualsToken it is interpreted as CoverInitializedName production + // CoverInitializedName[Yield] : + // IdentifierReference[?Yield] Initializer[In, ?Yield] + // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern + var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */ || token === 56 /* EqualsToken */); + if (isShorthandPropertyAssignment) { + var shorthandDeclaration = createNode(246 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; + var equalsToken = parseOptionalToken(56 /* EqualsToken */); + if (equalsToken) { + shorthandDeclaration.equalsToken = equalsToken; + shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); + } return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(243 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(245 /* PropertyAssignment */, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(53 /* ColonToken */); + parseExpected(54 /* ColonToken */); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(163 /* ObjectLiteralExpression */); + var node = createNode(165 /* ObjectLiteralExpression */); parseExpected(15 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048 /* MultiLine */; @@ -10519,9 +10820,9 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(171 /* FunctionExpression */); + var node = createNode(173 /* FunctionExpression */); setModifiers(node, parseModifiers()); - parseExpected(85 /* FunctionKeyword */); + parseExpected(87 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512 /* Async */); @@ -10530,7 +10831,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -10541,8 +10842,8 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(167 /* NewExpression */); - parseExpected(90 /* NewKeyword */); + var node = createNode(169 /* NewExpression */); + parseExpected(92 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token === 17 /* OpenParenToken */) { @@ -10552,7 +10853,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(190 /* Block */); + var node = createNode(192 /* Block */); if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(16 /* CloseBraceToken */); @@ -10582,25 +10883,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(192 /* EmptyStatement */); + var node = createNode(194 /* EmptyStatement */); parseExpected(23 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(194 /* IfStatement */); - parseExpected(86 /* IfKeyword */); + var node = createNode(196 /* IfStatement */); + parseExpected(88 /* IfKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(78 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(80 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(195 /* DoStatement */); - parseExpected(77 /* DoKeyword */); + var node = createNode(197 /* DoStatement */); + parseExpected(79 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(102 /* WhileKeyword */); + parseExpected(104 /* WhileKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); @@ -10612,8 +10913,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(196 /* WhileStatement */); - parseExpected(102 /* WhileKeyword */); + var node = createNode(198 /* WhileStatement */); + parseExpected(104 /* WhileKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); @@ -10622,11 +10923,11 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(84 /* ForKeyword */); + parseExpected(86 /* ForKeyword */); parseExpected(17 /* OpenParenToken */); var initializer = undefined; if (token !== 23 /* SemicolonToken */) { - if (token === 100 /* VarKeyword */ || token === 106 /* LetKeyword */ || token === 72 /* ConstKeyword */) { + if (token === 102 /* VarKeyword */ || token === 108 /* LetKeyword */ || token === 74 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -10634,22 +10935,22 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(88 /* InKeyword */)) { - var forInStatement = createNode(198 /* ForInStatement */, pos); + if (parseOptional(90 /* InKeyword */)) { + var forInStatement = createNode(200 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(132 /* OfKeyword */)) { - var forOfStatement = createNode(199 /* ForOfStatement */, pos); + else if (parseOptional(134 /* OfKeyword */)) { + var forOfStatement = createNode(201 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(197 /* ForStatement */, pos); + var forStatement = createNode(199 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(23 /* SemicolonToken */); if (token !== 23 /* SemicolonToken */ && token !== 18 /* CloseParenToken */) { @@ -10667,7 +10968,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */); + parseExpected(kind === 203 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -10675,8 +10976,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(202 /* ReturnStatement */); - parseExpected(92 /* ReturnKeyword */); + var node = createNode(204 /* ReturnStatement */); + parseExpected(94 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -10684,8 +10985,8 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(203 /* WithStatement */); - parseExpected(103 /* WithKeyword */); + var node = createNode(205 /* WithStatement */); + parseExpected(105 /* WithKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); @@ -10693,30 +10994,30 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(239 /* CaseClause */); - parseExpected(69 /* CaseKeyword */); + var node = createNode(241 /* CaseClause */); + parseExpected(71 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(53 /* ColonToken */); + parseExpected(54 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(240 /* DefaultClause */); - parseExpected(75 /* DefaultKeyword */); - parseExpected(53 /* ColonToken */); + var node = createNode(242 /* DefaultClause */); + parseExpected(77 /* DefaultKeyword */); + parseExpected(54 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 69 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token === 71 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(204 /* SwitchStatement */); - parseExpected(94 /* SwitchKeyword */); + var node = createNode(206 /* SwitchStatement */); + parseExpected(96 /* SwitchKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); - var caseBlock = createNode(218 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(220 /* CaseBlock */, scanner.getStartPos()); parseExpected(15 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(16 /* CloseBraceToken */); @@ -10731,29 +11032,29 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(206 /* ThrowStatement */); - parseExpected(96 /* ThrowKeyword */); + var node = createNode(208 /* ThrowStatement */); + parseExpected(98 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(207 /* TryStatement */); - parseExpected(98 /* TryKeyword */); + var node = createNode(209 /* TryStatement */); + parseExpected(100 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token === 70 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token === 72 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token === 83 /* FinallyKeyword */) { - parseExpected(83 /* FinallyKeyword */); + if (!node.catchClause || token === 85 /* FinallyKeyword */) { + parseExpected(85 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(242 /* CatchClause */); - parseExpected(70 /* CatchKeyword */); + var result = createNode(244 /* CatchClause */); + parseExpected(72 /* CatchKeyword */); if (parseExpected(17 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } @@ -10762,8 +11063,8 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(208 /* DebuggerStatement */); - parseExpected(74 /* DebuggerKeyword */); + var node = createNode(210 /* DebuggerStatement */); + parseExpected(76 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -10773,14 +11074,14 @@ var ts; // a colon. var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 67 /* Identifier */ && parseOptional(53 /* ColonToken */)) { - var labeledStatement = createNode(205 /* LabeledStatement */, fullStart); + if (expression.kind === 69 /* Identifier */ && parseOptional(54 /* ColonToken */)) { + var labeledStatement = createNode(207 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(193 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(195 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -10792,7 +11093,7 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 85 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token === 87 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -10801,12 +11102,12 @@ var ts; function isDeclaration() { while (true) { switch (token) { - case 100 /* VarKeyword */: - case 106 /* LetKeyword */: - case 72 /* ConstKeyword */: - case 85 /* FunctionKeyword */: - case 71 /* ClassKeyword */: - case 79 /* EnumKeyword */: + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: + case 87 /* FunctionKeyword */: + case 73 /* ClassKeyword */: + case 81 /* EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -10829,36 +11130,36 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 105 /* InterfaceKeyword */: - case 130 /* TypeKeyword */: + case 107 /* InterfaceKeyword */: + case 132 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 123 /* ModuleKeyword */: - case 124 /* NamespaceKeyword */: + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 116 /* AsyncKeyword */: - case 120 /* DeclareKeyword */: + case 115 /* AbstractKeyword */: + case 118 /* AsyncKeyword */: + case 122 /* DeclareKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 112 /* PublicKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 87 /* ImportKeyword */: + case 89 /* ImportKeyword */: nextToken(); return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ || token === 15 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token); - case 80 /* ExportKeyword */: + case 82 /* ExportKeyword */: nextToken(); - if (token === 55 /* EqualsToken */ || token === 37 /* AsteriskToken */ || - token === 15 /* OpenBraceToken */ || token === 75 /* DefaultKeyword */) { + if (token === 56 /* EqualsToken */ || token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */ || token === 77 /* DefaultKeyword */) { return true; } continue; - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 111 /* StaticKeyword */: - case 113 /* AbstractKeyword */: + case 113 /* StaticKeyword */: nextToken(); continue; default: @@ -10871,47 +11172,47 @@ var ts; } function isStartOfStatement() { switch (token) { - case 54 /* AtToken */: + case 55 /* AtToken */: case 23 /* SemicolonToken */: case 15 /* OpenBraceToken */: - case 100 /* VarKeyword */: - case 106 /* LetKeyword */: - case 85 /* FunctionKeyword */: - case 71 /* ClassKeyword */: - case 79 /* EnumKeyword */: - case 86 /* IfKeyword */: - case 77 /* DoKeyword */: - case 102 /* WhileKeyword */: - case 84 /* ForKeyword */: - case 73 /* ContinueKeyword */: - case 68 /* BreakKeyword */: - case 92 /* ReturnKeyword */: - case 103 /* WithKeyword */: - case 94 /* SwitchKeyword */: - case 96 /* ThrowKeyword */: - case 98 /* TryKeyword */: - case 74 /* DebuggerKeyword */: + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 87 /* FunctionKeyword */: + case 73 /* ClassKeyword */: + case 81 /* EnumKeyword */: + case 88 /* IfKeyword */: + case 79 /* DoKeyword */: + case 104 /* WhileKeyword */: + case 86 /* ForKeyword */: + case 75 /* ContinueKeyword */: + case 70 /* BreakKeyword */: + case 94 /* ReturnKeyword */: + case 105 /* WithKeyword */: + case 96 /* SwitchKeyword */: + case 98 /* ThrowKeyword */: + case 100 /* TryKeyword */: + case 76 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 70 /* CatchKeyword */: - case 83 /* FinallyKeyword */: + case 72 /* CatchKeyword */: + case 85 /* FinallyKeyword */: return true; - case 72 /* ConstKeyword */: - case 80 /* ExportKeyword */: - case 87 /* ImportKeyword */: + case 74 /* ConstKeyword */: + case 82 /* ExportKeyword */: + case 89 /* ImportKeyword */: return isStartOfDeclaration(); - case 116 /* AsyncKeyword */: - case 120 /* DeclareKeyword */: - case 105 /* InterfaceKeyword */: - case 123 /* ModuleKeyword */: - case 124 /* NamespaceKeyword */: - case 130 /* TypeKeyword */: + case 118 /* AsyncKeyword */: + case 122 /* DeclareKeyword */: + case 107 /* InterfaceKeyword */: + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: + case 132 /* TypeKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 111 /* StaticKeyword */: + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 113 /* StaticKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -10934,61 +11235,61 @@ var ts; return parseEmptyStatement(); case 15 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 100 /* VarKeyword */: + case 102 /* VarKeyword */: return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 106 /* LetKeyword */: + case 108 /* LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 85 /* FunctionKeyword */: + case 87 /* FunctionKeyword */: return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 71 /* ClassKeyword */: + case 73 /* ClassKeyword */: return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 86 /* IfKeyword */: + case 88 /* IfKeyword */: return parseIfStatement(); - case 77 /* DoKeyword */: + case 79 /* DoKeyword */: return parseDoStatement(); - case 102 /* WhileKeyword */: + case 104 /* WhileKeyword */: return parseWhileStatement(); - case 84 /* ForKeyword */: + case 86 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 73 /* ContinueKeyword */: - return parseBreakOrContinueStatement(200 /* ContinueStatement */); - case 68 /* BreakKeyword */: - return parseBreakOrContinueStatement(201 /* BreakStatement */); - case 92 /* ReturnKeyword */: + case 75 /* ContinueKeyword */: + return parseBreakOrContinueStatement(202 /* ContinueStatement */); + case 70 /* BreakKeyword */: + return parseBreakOrContinueStatement(203 /* BreakStatement */); + case 94 /* ReturnKeyword */: return parseReturnStatement(); - case 103 /* WithKeyword */: + case 105 /* WithKeyword */: return parseWithStatement(); - case 94 /* SwitchKeyword */: + case 96 /* SwitchKeyword */: return parseSwitchStatement(); - case 96 /* ThrowKeyword */: + case 98 /* ThrowKeyword */: return parseThrowStatement(); - case 98 /* TryKeyword */: + case 100 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 70 /* CatchKeyword */: - case 83 /* FinallyKeyword */: + case 72 /* CatchKeyword */: + case 85 /* FinallyKeyword */: return parseTryStatement(); - case 74 /* DebuggerKeyword */: + case 76 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 54 /* AtToken */: + case 55 /* AtToken */: return parseDeclaration(); - case 116 /* AsyncKeyword */: - case 105 /* InterfaceKeyword */: - case 130 /* TypeKeyword */: - case 123 /* ModuleKeyword */: - case 124 /* NamespaceKeyword */: - case 120 /* DeclareKeyword */: - case 72 /* ConstKeyword */: - case 79 /* EnumKeyword */: - case 80 /* ExportKeyword */: - case 87 /* ImportKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 110 /* PublicKeyword */: - case 113 /* AbstractKeyword */: - case 111 /* StaticKeyword */: + case 118 /* AsyncKeyword */: + case 107 /* InterfaceKeyword */: + case 132 /* TypeKeyword */: + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: + case 122 /* DeclareKeyword */: + case 74 /* ConstKeyword */: + case 81 /* EnumKeyword */: + case 82 /* ExportKeyword */: + case 89 /* ImportKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 112 /* PublicKeyword */: + case 115 /* AbstractKeyword */: + case 113 /* StaticKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -11001,35 +11302,35 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 100 /* VarKeyword */: - case 106 /* LetKeyword */: - case 72 /* ConstKeyword */: + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: return parseVariableStatement(fullStart, decorators, modifiers); - case 85 /* FunctionKeyword */: + case 87 /* FunctionKeyword */: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 71 /* ClassKeyword */: + case 73 /* ClassKeyword */: return parseClassDeclaration(fullStart, decorators, modifiers); - case 105 /* InterfaceKeyword */: + case 107 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 130 /* TypeKeyword */: + case 132 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 79 /* EnumKeyword */: + case 81 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 123 /* ModuleKeyword */: - case 124 /* NamespaceKeyword */: + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 87 /* ImportKeyword */: + case 89 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 80 /* ExportKeyword */: + case 82 /* ExportKeyword */: nextToken(); - return token === 75 /* DefaultKeyword */ || token === 55 /* EqualsToken */ ? + return token === 77 /* DefaultKeyword */ || token === 56 /* EqualsToken */ ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(229 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(231 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -11051,24 +11352,24 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token === 24 /* CommaToken */) { - return createNode(185 /* OmittedExpression */); + return createNode(187 /* OmittedExpression */); } - var node = createNode(161 /* BindingElement */); + var node = createNode(163 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(161 /* BindingElement */); + var node = createNode(163 /* BindingElement */); // TODO(andersh): Handle computed properties var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 53 /* ColonToken */) { + if (tokenIsIdentifier && token !== 54 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(53 /* ColonToken */); + parseExpected(54 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -11076,14 +11377,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(159 /* ObjectBindingPattern */); + var node = createNode(161 /* ObjectBindingPattern */); parseExpected(15 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(16 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(160 /* ArrayBindingPattern */); + var node = createNode(162 /* ArrayBindingPattern */); parseExpected(19 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(20 /* CloseBracketToken */); @@ -11102,7 +11403,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(209 /* VariableDeclaration */); + var node = createNode(211 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -11111,14 +11412,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(210 /* VariableDeclarationList */); + var node = createNode(212 /* VariableDeclarationList */); switch (token) { - case 100 /* VarKeyword */: + case 102 /* VarKeyword */: break; - case 106 /* LetKeyword */: + case 108 /* LetKeyword */: node.flags |= 16384 /* Let */; break; - case 72 /* ConstKeyword */: + case 74 /* ConstKeyword */: node.flags |= 32768 /* Const */; break; default: @@ -11134,7 +11435,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token === 132 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 134 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -11149,7 +11450,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(191 /* VariableStatement */, fullStart); + var node = createNode(193 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -11157,29 +11458,29 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(211 /* FunctionDeclaration */, fullStart); + var node = createNode(213 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(85 /* FunctionKeyword */); + parseExpected(87 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); node.name = node.flags & 1024 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512 /* Async */); - fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(142 /* Constructor */, pos); + var node = createNode(144 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(119 /* ConstructorKeyword */); - fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + parseExpected(121 /* ConstructorKeyword */); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(141 /* MethodDeclaration */, fullStart); + var method = createNode(143 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -11187,12 +11488,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512 /* Async */); - fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); + fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(139 /* PropertyDeclaration */, fullStart); + var property = createNode(141 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -11218,7 +11519,7 @@ var ts; var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(52 /* QuestionToken */); + var questionToken = parseOptionalToken(53 /* QuestionToken */); if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } @@ -11234,16 +11535,16 @@ var ts; node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 111 /* StaticKeyword */: + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 113 /* StaticKeyword */: return true; default: return false; @@ -11251,7 +11552,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 54 /* AtToken */) { + if (token === 55 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -11284,7 +11585,7 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 127 /* SetKeyword */ || idToken === 121 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 129 /* SetKeyword */ || idToken === 123 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -11292,9 +11593,9 @@ var ts; switch (token) { case 17 /* OpenParenToken */: // Method declaration case 25 /* LessThanToken */: // Generic Method declaration - case 53 /* ColonToken */: // Type Annotation for declaration - case 55 /* EqualsToken */: // Initializer for declaration - case 52 /* QuestionToken */: + case 54 /* ColonToken */: // Type Annotation for declaration + case 56 /* EqualsToken */: // Initializer for declaration + case 53 /* QuestionToken */: return true; default: // Covers @@ -11311,14 +11612,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(54 /* AtToken */)) { + if (!parseOptional(55 /* AtToken */)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(137 /* Decorator */, decoratorStart); + var decorator = createNode(139 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -11352,7 +11653,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 116 /* AsyncKeyword */) { + if (token === 118 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -11367,7 +11668,7 @@ var ts; } function parseClassElement() { if (token === 23 /* SemicolonToken */) { - var result = createNode(189 /* SemicolonClassElement */); + var result = createNode(191 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -11378,7 +11679,7 @@ var ts; if (accessor) { return accessor; } - if (token === 119 /* ConstructorKeyword */) { + if (token === 121 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -11395,7 +11696,7 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_7 = createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name_7 = createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. @@ -11405,17 +11706,17 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 184 /* ClassExpression */); + /*modifiers*/ undefined, 186 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 214 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(71 /* ClassKeyword */); - node.name = parseOptionalIdentifier(); + parseExpected(73 /* ClassKeyword */); + node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); if (parseExpected(15 /* OpenBraceToken */)) { @@ -11429,6 +11730,19 @@ var ts; } return finishNode(node); } + function parseNameOfClassDeclarationOrExpression() { + // implements is a future reserved word so + // 'class implements' might mean either + // - class expression with omitted name, 'implements' starts heritage clause + // - class with name 'implements' + // 'isImplementsClause' helps to disambiguate between these two cases + return isIdentifier() && !isImplementsClause() + ? parseIdentifier() + : undefined; + } + function isImplementsClause() { + return token === 106 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + } function parseHeritageClauses(isClassHeritageClause) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } @@ -11441,8 +11755,8 @@ var ts; return parseList(20 /* HeritageClauses */, parseHeritageClause); } function parseHeritageClause() { - if (token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */) { - var node = createNode(241 /* HeritageClause */); + if (token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */) { + var node = createNode(243 /* HeritageClause */); node.token = token; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -11451,7 +11765,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(186 /* ExpressionWithTypeArguments */); + var node = createNode(188 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 25 /* LessThanToken */) { node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); @@ -11459,16 +11773,16 @@ var ts; return finishNode(node); } function isHeritageClause() { - return token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; + return token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213 /* InterfaceDeclaration */, fullStart); + var node = createNode(215 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(105 /* InterfaceKeyword */); + parseExpected(107 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); @@ -11476,13 +11790,13 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214 /* TypeAliasDeclaration */, fullStart); + var node = createNode(216 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(130 /* TypeKeyword */); + parseExpected(132 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(55 /* EqualsToken */); + parseExpected(56 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -11492,16 +11806,16 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(245 /* EnumMember */, scanner.getStartPos()); + var node = createNode(247 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215 /* EnumDeclaration */, fullStart); + var node = createNode(217 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(79 /* EnumKeyword */); + parseExpected(81 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(15 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); @@ -11513,7 +11827,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(217 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(219 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(15 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(16 /* CloseBraceToken */); @@ -11524,7 +11838,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(216 /* ModuleDeclaration */, fullStart); + var node = createNode(218 /* ModuleDeclaration */, fullStart); // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 131072 /* Namespace */; @@ -11538,7 +11852,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216 /* ModuleDeclaration */, fullStart); + var node = createNode(218 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(/*internName*/ true); @@ -11547,11 +11861,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(124 /* NamespaceKeyword */)) { + if (parseOptional(126 /* NamespaceKeyword */)) { flags |= 131072 /* Namespace */; } else { - parseExpected(123 /* ModuleKeyword */); + parseExpected(125 /* ModuleKeyword */); if (token === 9 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -11559,42 +11873,42 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 125 /* RequireKeyword */ && + return token === 127 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 17 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 38 /* SlashToken */; + return nextToken() === 39 /* SlashToken */; } function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 24 /* CommaToken */ || - token === 131 /* FromKeyword */; + token === 133 /* FromKeyword */; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(87 /* ImportKeyword */); + parseExpected(89 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 24 /* CommaToken */ && token !== 131 /* FromKeyword */) { + if (token !== 24 /* CommaToken */ && token !== 133 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(219 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(221 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(55 /* EqualsToken */); + parseExpected(56 /* EqualsToken */); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } // Import statement - var importDeclaration = createNode(220 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(222 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: @@ -11604,7 +11918,7 @@ var ts; token === 37 /* AsteriskToken */ || token === 15 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(131 /* FromKeyword */); + parseExpected(133 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -11617,7 +11931,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(221 /* ImportClause */, fullStart); + var importClause = createNode(223 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -11627,7 +11941,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(24 /* CommaToken */)) { - importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(223 /* NamedImports */); + importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(225 /* NamedImports */); } return finishNode(importClause); } @@ -11637,8 +11951,8 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(230 /* ExternalModuleReference */); - parseExpected(125 /* RequireKeyword */); + var node = createNode(232 /* ExternalModuleReference */); + parseExpected(127 /* RequireKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(18 /* CloseParenToken */); @@ -11659,9 +11973,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(222 /* NamespaceImport */); + var namespaceImport = createNode(224 /* NamespaceImport */); parseExpected(37 /* AsteriskToken */); - parseExpected(114 /* AsKeyword */); + parseExpected(116 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -11674,14 +11988,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 223 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 225 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(228 /* ExportSpecifier */); + return parseImportOrExportSpecifier(230 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(224 /* ImportSpecifier */); + return parseImportOrExportSpecifier(226 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -11695,9 +12009,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 114 /* AsKeyword */) { + if (token === 116 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(114 /* AsKeyword */); + parseExpected(116 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -11706,27 +12020,27 @@ var ts; else { node.name = identifierName; } - if (kind === 224 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 226 /* ImportSpecifier */ && checkIdentifierIsKeyword) { // Report error identifier expected parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226 /* ExportDeclaration */, fullStart); + var node = createNode(228 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(37 /* AsteriskToken */)) { - parseExpected(131 /* FromKeyword */); + parseExpected(133 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(227 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(229 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token === 131 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(131 /* FromKeyword */); + if (token === 133 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(133 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -11734,14 +12048,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(225 /* ExportAssignment */, fullStart); + var node = createNode(227 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(55 /* EqualsToken */)) { + if (parseOptional(56 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(75 /* DefaultKeyword */); + parseExpected(77 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -11807,10 +12121,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ - || node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */ - || node.kind === 220 /* ImportDeclaration */ - || node.kind === 225 /* ExportAssignment */ - || node.kind === 226 /* ExportDeclaration */ + || node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 232 /* ExternalModuleReference */ + || node.kind === 222 /* ImportDeclaration */ + || node.kind === 227 /* ExportAssignment */ + || node.kind === 228 /* ExportDeclaration */ ? node : undefined; }); @@ -11856,22 +12170,22 @@ var ts; function isJSDocType() { switch (token) { case 37 /* AsteriskToken */: - case 52 /* QuestionToken */: + case 53 /* QuestionToken */: case 17 /* OpenParenToken */: case 19 /* OpenBracketToken */: - case 48 /* ExclamationToken */: + case 49 /* ExclamationToken */: case 15 /* OpenBraceToken */: - case 85 /* FunctionKeyword */: + case 87 /* FunctionKeyword */: case 22 /* DotDotDotToken */: - case 90 /* NewKeyword */: - case 95 /* ThisKeyword */: + case 92 /* NewKeyword */: + case 97 /* ThisKeyword */: return true; } return ts.tokenIsIdentifierOrKeyword(token); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); + initializeState("file.js", content, 2 /* Latest */, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined); var jsDocTypeExpression = parseJSDocTypeExpression(start, length); var diagnostics = parseDiagnostics; clearState(); @@ -11885,7 +12199,7 @@ var ts; scanner.setText(sourceText, start, length); // Prime the first token for us to start processing. token = nextToken(); - var result = createNode(247 /* JSDocTypeExpression */); + var result = createNode(249 /* JSDocTypeExpression */); parseExpected(15 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(16 /* CloseBraceToken */); @@ -11895,13 +12209,13 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 46 /* BarToken */) { - var unionType = createNode(251 /* JSDocUnionType */, type.pos); + if (token === 47 /* BarToken */) { + var unionType = createNode(253 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 55 /* EqualsToken */) { - var optionalType = createNode(258 /* JSDocOptionalType */, type.pos); + if (token === 56 /* EqualsToken */) { + var optionalType = createNode(260 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -11912,20 +12226,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 19 /* OpenBracketToken */) { - var arrayType = createNode(250 /* JSDocArrayType */, type.pos); + var arrayType = createNode(252 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(20 /* CloseBracketToken */); type = finishNode(arrayType); } - else if (token === 52 /* QuestionToken */) { - var nullableType = createNode(253 /* JSDocNullableType */, type.pos); + else if (token === 53 /* QuestionToken */) { + var nullableType = createNode(255 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 48 /* ExclamationToken */) { - var nonNullableType = createNode(254 /* JSDocNonNullableType */, type.pos); + else if (token === 49 /* ExclamationToken */) { + var nonNullableType = createNode(256 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -11940,80 +12254,80 @@ var ts; switch (token) { case 37 /* AsteriskToken */: return parseJSDocAllType(); - case 52 /* QuestionToken */: + case 53 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); case 17 /* OpenParenToken */: return parseJSDocUnionType(); case 19 /* OpenBracketToken */: return parseJSDocTupleType(); - case 48 /* ExclamationToken */: + case 49 /* ExclamationToken */: return parseJSDocNonNullableType(); case 15 /* OpenBraceToken */: return parseJSDocRecordType(); - case 85 /* FunctionKeyword */: + case 87 /* FunctionKeyword */: return parseJSDocFunctionType(); case 22 /* DotDotDotToken */: return parseJSDocVariadicType(); - case 90 /* NewKeyword */: + case 92 /* NewKeyword */: return parseJSDocConstructorType(); - case 95 /* ThisKeyword */: + case 97 /* ThisKeyword */: return parseJSDocThisType(); - case 115 /* AnyKeyword */: - case 128 /* StringKeyword */: - case 126 /* NumberKeyword */: - case 118 /* BooleanKeyword */: - case 129 /* SymbolKeyword */: - case 101 /* VoidKeyword */: + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(262 /* JSDocThisType */); + var result = createNode(264 /* JSDocThisType */); nextToken(); - parseExpected(53 /* ColonToken */); + parseExpected(54 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(261 /* JSDocConstructorType */); + var result = createNode(263 /* JSDocConstructorType */); nextToken(); - parseExpected(53 /* ColonToken */); + parseExpected(54 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(260 /* JSDocVariadicType */); + var result = createNode(262 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(259 /* JSDocFunctionType */); + var result = createNode(261 /* JSDocFunctionType */); nextToken(); parseExpected(17 /* OpenParenToken */); result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(18 /* CloseParenToken */); - if (token === 53 /* ColonToken */) { + if (token === 54 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(136 /* Parameter */); + var parameter = createNode(138 /* Parameter */); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(258 /* JSDocOptionalType */, type.pos); + var result = createNode(260 /* JSDocOptionalType */, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(257 /* JSDocTypeReference */); + var result = createNode(259 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); while (parseOptional(21 /* DotToken */)) { if (token === 25 /* LessThanToken */) { @@ -12043,13 +12357,13 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(133 /* QualifiedName */, left.pos); + var result = createNode(135 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(255 /* JSDocRecordType */); + var result = createNode(257 /* JSDocRecordType */); nextToken(); result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember); checkForTrailingComma(result.members); @@ -12057,22 +12371,22 @@ var ts; return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(256 /* JSDocRecordMember */); + var result = createNode(258 /* JSDocRecordMember */); result.name = parseSimplePropertyName(); - if (token === 53 /* ColonToken */) { + if (token === 54 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(254 /* JSDocNonNullableType */); + var result = createNode(256 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(252 /* JSDocTupleType */); + var result = createNode(254 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); @@ -12086,7 +12400,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(251 /* JSDocUnionType */); + var result = createNode(253 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(18 /* CloseParenToken */); @@ -12097,14 +12411,14 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(46 /* BarToken */)) { + while (parseOptional(47 /* BarToken */)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(248 /* JSDocAllType */); + var result = createNode(250 /* JSDocAllType */); nextToken(); return finishNode(result); } @@ -12125,19 +12439,19 @@ var ts; token === 16 /* CloseBraceToken */ || token === 18 /* CloseParenToken */ || token === 27 /* GreaterThanToken */ || - token === 55 /* EqualsToken */ || - token === 46 /* BarToken */) { - var result = createNode(249 /* JSDocUnknownType */, pos); + token === 56 /* EqualsToken */ || + token === 47 /* BarToken */) { + var result = createNode(251 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(253 /* JSDocNullableType */, pos); + var result = createNode(255 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); + initializeState("file.js", content, 2 /* Latest */, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined); var jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length); var diagnostics = parseDiagnostics; clearState(); @@ -12219,7 +12533,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(263 /* JSDocComment */, start); + var result = createNode(265 /* JSDocComment */, start); result.tags = tags; return finishNode(result, end); } @@ -12230,7 +12544,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64 /* at */); - var atToken = createNode(54 /* AtToken */, pos - 1); + var atToken = createNode(55 /* AtToken */, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -12256,7 +12570,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(264 /* JSDocTag */, atToken.pos); + var result = createNode(266 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -12307,7 +12621,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(265 /* JSDocParameterTag */, atToken.pos); + var result = createNode(267 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -12317,27 +12631,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 266 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 268 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(266 /* JSDocReturnTag */, atToken.pos); + var result = createNode(268 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 267 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 269 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(267 /* JSDocTypeTag */, atToken.pos); + var result = createNode(269 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 268 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 270 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -12350,7 +12664,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(135 /* TypeParameter */, name_8.pos); + var typeParameter = createNode(137 /* TypeParameter */, name_8.pos); typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -12361,7 +12675,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(268 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(270 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -12382,7 +12696,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(67 /* Identifier */, startPos); + var result = createNode(69 /* Identifier */, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -12505,7 +12819,7 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 67 /* Identifier */: + case 69 /* Identifier */: return true; } return false; @@ -12898,17 +13212,19 @@ var ts; var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); var typeCount = 0; + var symbolCount = 0; var emptyArray = []; var emptySymbols = {}; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0 /* ES3 */; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */; var emitResolver = createResolver(); var undefinedSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "undefined"); var argumentsSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "arguments"); var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, - getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount"); }, + getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, getTypeCount: function () { return typeCount; }, isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, @@ -12999,6 +13315,7 @@ var ts; var getInstantiatedGlobalPromiseLikeType; var getGlobalPromiseConstructorLikeType; var getGlobalThenableType; + var cjsRequireType; var tupleTypes = {}; var unionTypes = {}; var intersectionTypes = {}; @@ -13069,6 +13386,7 @@ var ts; diagnostics.add(diagnostic); } function createSymbol(flags, name) { + symbolCount++; return new Symbol(flags, name); } function getExcludedSymbolFlags(flags) { @@ -13198,10 +13516,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 246 /* SourceFile */); + return ts.getAncestor(node, 248 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 246 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 248 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -13220,18 +13538,62 @@ var ts; } // return undefined if we can't find a symbol. } - /** Returns true if node1 is defined before node 2**/ - function isDefinedBefore(node1, node2) { - var file1 = ts.getSourceFileOfNode(node1); - var file2 = ts.getSourceFileOfNode(node2); - if (file1 === file2) { - return node1.pos <= node2.pos; + function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { + var declarationFile = ts.getSourceFileOfNode(declaration); + var useFile = ts.getSourceFileOfNode(usage); + if (declarationFile !== useFile) { + if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) { + // nodes are in different files and order cannot be determines + return true; + } + var sourceFiles = host.getSourceFiles(); + return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); + } + if (declaration.pos <= usage.pos) { + // declaration is before usage + // still might be illegal if usage is in the initializer of the variable declaration + return declaration.kind !== 211 /* VariableDeclaration */ || + !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + // declaration is after usage + // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) + return isUsedInFunctionOrNonStaticProperty(declaration, usage); + function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + if (declaration.parent.parent.kind === 193 /* VariableStatement */ || + declaration.parent.parent.kind === 199 /* ForStatement */) { + // variable statement/for statement case, + // use site should not be inside variable declaration (initializer of declaration or binding element) + return isSameScopeDescendentOf(usage, declaration, container); + } + else if (declaration.parent.parent.kind === 201 /* ForOfStatement */ || + declaration.parent.parent.kind === 200 /* ForInStatement */) { + // ForIn/ForOf case - use site should not be used in expression part + var expression = declaration.parent.parent.expression; + return isSameScopeDescendentOf(usage, expression, container); + } } - if (!compilerOptions.outFile && !compilerOptions.out) { - return true; + function isUsedInFunctionOrNonStaticProperty(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + var current = usage; + while (current) { + if (current === container) { + return false; + } + if (ts.isFunctionLike(current)) { + return true; + } + var initializerOfNonStaticProperty = current.parent && + current.parent.kind === 141 /* PropertyDeclaration */ && + (current.parent.flags & 128 /* Static */) === 0 && + current.parent.initializer === current; + if (initializerOfNonStaticProperty) { + return true; + } + current = current.parent; + } + return false; } - var sourceFiles = host.getSourceFiles(); - return sourceFiles.indexOf(file1) <= sourceFiles.indexOf(file2); } // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and // the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with @@ -13258,13 +13620,13 @@ var ts; } } switch (location.kind) { - case 246 /* SourceFile */: - if (!ts.isExternalModule(location)) + case 248 /* SourceFile */: + if (!ts.isExternalOrCommonJsModule(location)) break; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 246 /* SourceFile */ || - (location.kind === 216 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) { + if (location.kind === 248 /* SourceFile */ || + (location.kind === 218 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) { // It's an external module. Because of module/namespace merging, a module's exports are in scope, // yet we never want to treat an export specifier as putting a member in scope. Therefore, // if the name we find is purely an export specifier, it is not actually considered in scope. @@ -13278,7 +13640,7 @@ var ts; // which is not the desired behavior. if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 228 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 230 /* ExportSpecifier */)) { break; } result = moduleExports["default"]; @@ -13292,13 +13654,13 @@ var ts; break loop; } break; - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -13315,9 +13677,9 @@ var ts; } } break; - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 213 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -13328,7 +13690,7 @@ var ts; } break loop; } - if (location.kind === 184 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 186 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -13344,9 +13706,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 213 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 215 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -13354,19 +13716,19 @@ var ts; } } break; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: - case 172 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 171 /* FunctionExpression */: + case 173 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -13379,7 +13741,7 @@ var ts; } } break; - case 137 /* Decorator */: + case 139 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -13388,7 +13750,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 136 /* Parameter */) { + if (location.parent && location.parent.kind === 138 /* Parameter */) { location = location.parent; } // @@ -13434,8 +13796,11 @@ var ts; // block - scope variable and namespace module. However, only when we // try to resolve name in /*1*/ which is used in variable position, // we want to check for block- scoped - if (meaning & 2 /* BlockScopedVariable */ && result.flags & 2 /* BlockScopedVariable */) { - checkResolvedBlockScopedVariable(result, errorLocation); + if (meaning & 2 /* BlockScopedVariable */) { + var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); + if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */) { + checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); + } } } return result; @@ -13445,32 +13810,7 @@ var ts; // Block-scoped variables cannot be used before their definition var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - // first check if usage is lexically located after the declaration - var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); - if (!isUsedBeforeDeclaration) { - // lexical check succeeded however code still can be illegal. - // - block scoped variables cannot be used in its initializers - // let x = x; // illegal but usage is lexically after definition - // - in ForIn/ForOf statements variable cannot be contained in expression part - // for (let x in x) - // for (let x of x) - // climb up to the variable declaration skipping binding patterns - var variableDeclaration = ts.getAncestor(declaration, 209 /* VariableDeclaration */); - var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 191 /* VariableStatement */ || - variableDeclaration.parent.parent.kind === 197 /* ForStatement */) { - // variable statement/for statement case, - // use site should not be inside variable declaration (initializer of declaration or binding element) - isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); - } - else if (variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */ || - variableDeclaration.parent.parent.kind === 198 /* ForInStatement */) { - // ForIn/ForOf case - use site should not be used in expression part - var expression = variableDeclaration.parent.parent.expression; - isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); - } - } - if (isUsedBeforeDeclaration) { + if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 211 /* VariableDeclaration */), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -13491,10 +13831,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 219 /* ImportEqualsDeclaration */) { + if (node.kind === 221 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 220 /* ImportDeclaration */) { + while (node && node.kind !== 222 /* ImportDeclaration */) { node = node.parent; } return node; @@ -13504,7 +13844,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 230 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 232 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -13611,17 +13951,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 221 /* ImportClause */: + case 223 /* ImportClause */: return getTargetOfImportClause(node); - case 222 /* NamespaceImport */: + case 224 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 224 /* ImportSpecifier */: + case 226 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 228 /* ExportSpecifier */: + case 230 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -13666,11 +14006,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 225 /* ExportAssignment */) { + if (node.kind === 227 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 228 /* ExportSpecifier */) { + else if (node.kind === 230 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -13683,7 +14023,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 219 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 221 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -13692,17 +14032,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 67 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 69 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 67 /* Identifier */ || entityName.parent.kind === 133 /* QualifiedName */) { + if (entityName.kind === 69 /* Identifier */ || entityName.parent.kind === 135 /* QualifiedName */) { return resolveEntityName(entityName, 1536 /* Namespace */); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 219 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 221 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -13715,16 +14055,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 67 /* Identifier */) { + if (name.kind === 69 /* Identifier */) { var message = meaning === 1536 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 133 /* QualifiedName */ || name.kind === 164 /* PropertyAccessExpression */) { - var left = name.kind === 133 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 133 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 135 /* QualifiedName */ || name.kind === 166 /* PropertyAccessExpression */) { + var left = name.kind === 135 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 135 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -13743,11 +14083,6 @@ var ts; ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); return symbol.flags & meaning ? symbol : resolveAlias(symbol); } - function isExternalModuleNameRelative(moduleName) { - // TypeScript 1.0 spec (April 2014): 11.2.1 - // An external module name is "relative" if the first term is "." or "..". - return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; - } function resolveExternalModuleName(location, moduleReferenceExpression) { if (moduleReferenceExpression.kind !== 9 /* StringLiteral */) { return; @@ -13760,7 +14095,10 @@ var ts; if (moduleName === undefined) { return; } - var isRelative = isExternalModuleNameRelative(moduleName); + if (moduleName.indexOf("!") >= 0) { + moduleName = moduleName.substr(0, moduleName.indexOf("!")); + } + var isRelative = ts.isExternalModuleNameRelative(moduleName); if (!isRelative) { var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512 /* ValueModule */); if (symbol) { @@ -13876,7 +14214,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 142 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 144 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -13946,17 +14284,17 @@ var ts; } } switch (location_1.kind) { - case 246 /* SourceFile */: - if (!ts.isExternalModule(location_1)) { + case 248 /* SourceFile */: + if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -13997,7 +14335,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -14034,7 +14372,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -14107,8 +14445,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 216 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) || - (declaration.kind === 246 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 218 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) || + (declaration.kind === 248 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -14144,12 +14482,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 152 /* TypeQuery */) { + if (entityName.parent.kind === 154 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 133 /* QualifiedName */ || entityName.kind === 164 /* PropertyAccessExpression */ || - entityName.parent.kind === 219 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 135 /* QualifiedName */ || entityName.kind === 166 /* PropertyAccessExpression */ || + entityName.parent.kind === 221 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -14204,10 +14542,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 158 /* ParenthesizedType */) { + while (node.kind === 160 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 214 /* TypeAliasDeclaration */) { + if (node.kind === 216 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -14221,10 +14559,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 184 /* ClassExpression */: + case 186 /* ClassExpression */: return "(Anonymous class)"; - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -14307,6 +14645,7 @@ var ts; } function buildTypeDisplay(type, writer, enclosingDeclaration, globalFlags, symbolStack) { var globalFlagsToPass = globalFlags & 16 /* WriteOwnNameForAnyLike */; + var inObjectTypeLiteral = false; return writeType(type, globalFlags); function writeType(type, flags) { // Write undefined/null type as any @@ -14316,6 +14655,12 @@ var ts; ? "any" : type.intrinsicName); } + else if (type.flags & 33554432 /* ThisType */) { + if (inObjectTypeLiteral) { + writer.reportInaccessibleThisError(); + } + writer.writeKeyword("this"); + } else if (type.flags & 4096 /* Reference */) { writeTypeReference(type, flags); } @@ -14357,11 +14702,10 @@ var ts; writeType(types[i], delimiter === 24 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); } } - function writeSymbolTypeReference(symbol, typeArguments, pos, end) { - // Unnamed function expressions, arrow functions, and unnamed class expressions have reserved names that - // we don't want to display - if (!isReservedMemberName(symbol.name)) { - buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056 /* Type */); + function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { + // Unnamed function expressions and arrow functions have reserved names that we don't want to display + if (symbol.flags & 32 /* Class */ || !isReservedMemberName(symbol.name)) { + buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056 /* Type */, 0 /* None */, flags); } if (pos < end) { writePunctuation(writer, 25 /* LessThanToken */); @@ -14375,7 +14719,7 @@ var ts; } } function writeTypeReference(type, flags) { - var typeArguments = type.typeArguments; + var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { writeType(typeArguments[0], 64 /* InElementType */); writePunctuation(writer, 19 /* OpenBracketToken */); @@ -14399,12 +14743,13 @@ var ts; // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_3, typeArguments, start, i); + writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); writePunctuation(writer, 21 /* DotToken */); } } } - writeSymbolTypeReference(type.symbol, typeArguments, i, typeArguments.length); + var typeParameterCount = (type.target.typeParameters || emptyArray).length; + writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags); } } function writeTupleType(type) { @@ -14416,7 +14761,7 @@ var ts; if (flags & 64 /* InElementType */) { writePunctuation(writer, 17 /* OpenParenToken */); } - writeTypeList(type.types, type.flags & 16384 /* Union */ ? 46 /* BarToken */ : 45 /* AmpersandToken */); + writeTypeList(type.types, type.flags & 16384 /* Union */ ? 47 /* BarToken */ : 46 /* AmpersandToken */); if (flags & 64 /* InElementType */) { writePunctuation(writer, 18 /* CloseParenToken */); } @@ -14440,7 +14785,7 @@ var ts; } else { // Recursive usage, use any - writeKeyword(writer, 115 /* AnyKeyword */); + writeKeyword(writer, 117 /* AnyKeyword */); } } else { @@ -14464,7 +14809,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 246 /* SourceFile */ || declaration.parent.kind === 217 /* ModuleBlock */; + return declaration.parent.kind === 248 /* SourceFile */ || declaration.parent.kind === 219 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -14474,7 +14819,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 99 /* TypeOfKeyword */); + writeKeyword(writer, 101 /* TypeOfKeyword */); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } @@ -14510,7 +14855,7 @@ var ts; if (flags & 64 /* InElementType */) { writePunctuation(writer, 17 /* OpenParenToken */); } - writeKeyword(writer, 90 /* NewKeyword */); + writeKeyword(writer, 92 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); if (flags & 64 /* InElementType */) { @@ -14519,6 +14864,8 @@ var ts; return; } } + var saveInObjectTypeLiteral = inObjectTypeLiteral; + inObjectTypeLiteral = true; writePunctuation(writer, 15 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); @@ -14530,7 +14877,7 @@ var ts; } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 90 /* NewKeyword */); + writeKeyword(writer, 92 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 23 /* SemicolonToken */); @@ -14540,11 +14887,11 @@ var ts; // [x: string]: writePunctuation(writer, 19 /* OpenBracketToken */); writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, /*fallbackName*/ "x")); - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 128 /* StringKeyword */); + writeKeyword(writer, 130 /* StringKeyword */); writePunctuation(writer, 20 /* CloseBracketToken */); - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); writeType(resolved.stringIndexType, 0 /* None */); writePunctuation(writer, 23 /* SemicolonToken */); @@ -14554,11 +14901,11 @@ var ts; // [x: number]: writePunctuation(writer, 19 /* OpenBracketToken */); writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, /*fallbackName*/ "x")); - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 126 /* NumberKeyword */); + writeKeyword(writer, 128 /* NumberKeyword */); writePunctuation(writer, 20 /* CloseBracketToken */); - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); writeType(resolved.numberIndexType, 0 /* None */); writePunctuation(writer, 23 /* SemicolonToken */); @@ -14573,7 +14920,7 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 52 /* QuestionToken */); + writePunctuation(writer, 53 /* QuestionToken */); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 23 /* SemicolonToken */); @@ -14583,9 +14930,9 @@ var ts; else { buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 52 /* QuestionToken */); + writePunctuation(writer, 53 /* QuestionToken */); } - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); writePunctuation(writer, 23 /* SemicolonToken */); @@ -14594,6 +14941,7 @@ var ts; } writer.decreaseIndent(); writePunctuation(writer, 16 /* CloseBraceToken */); + inObjectTypeLiteral = saveInObjectTypeLiteral; } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { @@ -14607,7 +14955,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 81 /* ExtendsKeyword */); + writeKeyword(writer, 83 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -14619,9 +14967,9 @@ var ts; } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 52 /* QuestionToken */); + writePunctuation(writer, 53 /* QuestionToken */); } - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } @@ -14668,14 +15016,14 @@ var ts; writePunctuation(writer, 34 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 122 /* IsKeyword */); + writeKeyword(writer, 124 /* IsKeyword */); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -14711,13 +15059,13 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 216 /* ModuleDeclaration */) { + if (node.kind === 218 /* ModuleDeclaration */) { if (node.name.kind === 9 /* StringLiteral */) { return node; } } - else if (node.kind === 246 /* SourceFile */) { - return ts.isExternalModule(node) ? node : undefined; + else if (node.kind === 248 /* SourceFile */) { + return ts.isExternalOrCommonJsModule(node) ? node : undefined; } } ts.Debug.fail("getContainingModule cant reach here"); @@ -14765,70 +15113,70 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 161 /* BindingElement */: + case 163 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 209 /* VariableDeclaration */: + case 211 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // Otherwise fall through - case 216 /* ModuleDeclaration */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 211 /* FunctionDeclaration */: - case 215 /* EnumDeclaration */: - case 219 /* ImportEqualsDeclaration */: + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 213 /* FunctionDeclaration */: + case 217 /* EnumDeclaration */: + case 221 /* ImportEqualsDeclaration */: var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && - !(node.kind !== 219 /* ImportEqualsDeclaration */ && parent_4.kind !== 246 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 221 /* ImportEqualsDeclaration */ && parent_4.kind !== 248 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_4); - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so let it fall into next case statement - case 142 /* Constructor */: - case 146 /* ConstructSignature */: - case 145 /* CallSignature */: - case 147 /* IndexSignature */: - case 136 /* Parameter */: - case 217 /* ModuleBlock */: - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 153 /* TypeLiteral */: - case 149 /* TypeReference */: - case 154 /* ArrayType */: - case 155 /* TupleType */: - case 156 /* UnionType */: - case 157 /* IntersectionType */: - case 158 /* ParenthesizedType */: + case 144 /* Constructor */: + case 148 /* ConstructSignature */: + case 147 /* CallSignature */: + case 149 /* IndexSignature */: + case 138 /* Parameter */: + case 219 /* ModuleBlock */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 155 /* TypeLiteral */: + case 151 /* TypeReference */: + case 156 /* ArrayType */: + case 157 /* TupleType */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: + case 160 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 221 /* ImportClause */: - case 222 /* NamespaceImport */: - case 224 /* ImportSpecifier */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: + case 226 /* ImportSpecifier */: return false; // Type parameters are always visible - case 135 /* TypeParameter */: + case 137 /* TypeParameter */: // Source file is always visible - case 246 /* SourceFile */: + case 248 /* SourceFile */: return true; - // Export assignements do not create name bindings outside the module - case 225 /* ExportAssignment */: + // Export assignments do not create name bindings outside the module + case 227 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -14844,10 +15192,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 225 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 227 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 228 /* ExportSpecifier */) { + else if (node.parent.kind === 230 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -14939,7 +15287,7 @@ var ts; node = ts.getRootDeclaration(node); // Parent chain: // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 209 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + return node.kind === 211 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -14957,10 +15305,16 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1 /* Any */) !== 0; } + // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been + // assigned by contextual typing. + function getTypeForBindingElementParent(node) { + var symbol = getSymbolOfNode(node); + return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node); + } // Return the inferred type for a binding element function getTypeForBindingElement(declaration) { var pattern = declaration.parent; - var parentType = getTypeForVariableLikeDeclaration(pattern.parent); + var parentType = getTypeForBindingElementParent(pattern.parent); // If parent has the unknown (error) type, then so does this binding element if (parentType === unknownType) { return unknownType; @@ -14975,7 +15329,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 159 /* ObjectBindingPattern */) { + if (pattern.kind === 161 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_10 = declaration.propertyName || declaration.name; // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, @@ -15019,10 +15373,10 @@ var ts; // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration) { // A variable declared in a for..in statement is always of type any - if (declaration.parent.parent.kind === 198 /* ForInStatement */) { + if (declaration.parent.parent.kind === 200 /* ForInStatement */) { return anyType; } - if (declaration.parent.parent.kind === 199 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 201 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -15036,11 +15390,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 136 /* Parameter */) { + if (declaration.kind === 138 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 144 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143 /* GetAccessor */); + if (func.kind === 146 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -15056,7 +15410,7 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 244 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 246 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -15102,7 +15456,7 @@ var ts; return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType; } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. - var elementTypes = ts.map(elements, function (e) { return e.kind === 185 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + var elementTypes = ts.map(elements, function (e) { return e.kind === 187 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); if (includePatternInType) { var result = createNewTupleType(elementTypes); result.pattern = pattern; @@ -15118,7 +15472,7 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern, includePatternInType) { - return pattern.kind === 159 /* ObjectBindingPattern */ + return pattern.kind === 161 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType) : getTypeFromArrayBindingPattern(pattern, includePatternInType); } @@ -15140,14 +15494,14 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - return declaration.kind !== 243 /* PropertyAssignment */ ? getWidenedType(type) : type; + return declaration.kind !== 245 /* PropertyAssignment */ ? getWidenedType(type) : type; } // Rest parameters default to type any[], other parameters default to type any type = declaration.dotDotDotToken ? anyArrayType : anyType; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 136 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 138 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -15162,13 +15516,21 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 242 /* CatchClause */) { + if (declaration.parent.kind === 244 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 225 /* ExportAssignment */) { + if (declaration.kind === 227 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } + // Handle module.exports = expr + if (declaration.kind === 181 /* BinaryExpression */) { + return links.type = checkExpression(declaration.right); + } + // Handle exports.p = expr + if (declaration.kind === 166 /* PropertyAccessExpression */) { + return checkExpressionCached(declaration.parent.right); + } // Handle variable, parameter or property if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; @@ -15194,7 +15556,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 143 /* GetAccessor */) { + if (accessor.kind === 145 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -15210,8 +15572,8 @@ var ts; if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 143 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 144 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 146 /* SetAccessor */); var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); @@ -15240,7 +15602,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 143 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */); error(getter_1, 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)); } } @@ -15340,9 +15702,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */ || - node.kind === 211 /* FunctionDeclaration */ || node.kind === 171 /* FunctionExpression */ || - node.kind === 141 /* MethodDeclaration */ || node.kind === 172 /* ArrowFunction */) { + if (node.kind === 214 /* ClassDeclaration */ || node.kind === 186 /* ClassExpression */ || + node.kind === 213 /* FunctionDeclaration */ || node.kind === 173 /* FunctionExpression */ || + node.kind === 143 /* MethodDeclaration */ || node.kind === 174 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -15352,7 +15714,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 215 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -15361,8 +15723,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 212 /* ClassDeclaration */ || - node.kind === 184 /* ClassExpression */ || node.kind === 214 /* TypeAliasDeclaration */) { + if (node.kind === 215 /* InterfaceDeclaration */ || node.kind === 214 /* ClassDeclaration */ || + node.kind === 186 /* ClassExpression */ || node.kind === 216 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -15482,7 +15844,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 213 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 215 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -15503,6 +15865,32 @@ var ts; } } } + // Returns true if the interface given by the symbol is free of "this" references. Specifically, the result is + // true if the interface itself contains no references to "this" in its body, if all base types are interfaces, + // and if none of the base interfaces have a "this" type. + function isIndependentInterface(symbol) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 215 /* InterfaceDeclaration */) { + if (declaration.flags & 524288 /* ContainsThis */) { + return false; + } + var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); + if (baseTypeNodes) { + for (var _b = 0; _b < baseTypeNodes.length; _b++) { + var node = baseTypeNodes[_b]; + if (ts.isSupportedExpressionWithTypeArguments(node)) { + var baseSymbol = resolveEntityName(node.expression, 793056 /* Type */, /*ignoreErrors*/ true); + if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + return false; + } + } + } + } + } + } + return true; + } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { @@ -15510,7 +15898,12 @@ var ts; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - if (outerTypeParameters || localTypeParameters) { + // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type + // because it is not feasible to analyze all members to determine if the "this" type escapes the class (in particular, + // property types inferred from initializers and method return types inferred from return statements are very hard + // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of + // "this" references. + if (outerTypeParameters || localTypeParameters || kind === 1024 /* Class */ || !isIndependentInterface(symbol)) { type.flags |= 4096 /* Reference */; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; @@ -15519,6 +15912,9 @@ var ts; type.instantiations[getTypeListId(type.typeParameters)] = type; type.target = type; type.typeArguments = type.typeParameters; + type.thisType = createType(512 /* TypeParameter */ | 33554432 /* ThisType */); + type.thisType.symbol = symbol; + type.thisType.constraint = getTypeWithThisArgument(type); } } return links.declaredType; @@ -15531,7 +15927,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 214 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 216 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -15564,7 +15960,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -15597,6 +15993,79 @@ var ts; } return unknownType; } + // A type reference is considered independent if each type argument is considered independent. + function isIndependentTypeReference(node) { + if (node.typeArguments) { + for (var _i = 0, _a = node.typeArguments; _i < _a.length; _i++) { + var typeNode = _a[_i]; + if (!isIndependentType(typeNode)) { + return false; + } + } + } + return true; + } + // A type is considered independent if it the any, string, number, boolean, symbol, or void keyword, a string + // literal type, an array with an element type that is considered independent, or a type reference that is + // considered independent. + function isIndependentType(node) { + switch (node.kind) { + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: + case 9 /* StringLiteral */: + return true; + case 156 /* ArrayType */: + return isIndependentType(node.elementType); + case 151 /* TypeReference */: + return isIndependentTypeReference(node); + } + return false; + } + // A variable-like declaration is considered independent (free of this references) if it has a type annotation + // that specifies an independent type, or if it has no type annotation and no initializer (and thus of type any). + function isIndependentVariableLikeDeclaration(node) { + return node.type && isIndependentType(node.type) || !node.type && !node.initializer; + } + // A function-like declaration is considered independent (free of this references) if it has a return type + // annotation that is considered independent and if each parameter is considered independent. + function isIndependentFunctionLikeDeclaration(node) { + if (node.kind !== 144 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + return false; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + if (!isIndependentVariableLikeDeclaration(parameter)) { + return false; + } + } + return true; + } + // Returns true if the class or interface member given by the symbol is free of "this" references. The + // function may return false for symbols that are actually free of "this" references because it is not + // feasible to perform a complete analysis in all cases. In particular, property members with types + // inferred from their initializers and function members with inferred return types are convervatively + // assumed not to be free of "this" references. + function isIndependentMember(symbol) { + if (symbol.declarations && symbol.declarations.length === 1) { + var declaration = symbol.declarations[0]; + if (declaration) { + switch (declaration.kind) { + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return isIndependentVariableLikeDeclaration(declaration); + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + return isIndependentFunctionLikeDeclaration(declaration); + } + } + } + return false; + } function createSymbolTable(symbols) { var result = {}; for (var _i = 0; _i < symbols.length; _i++) { @@ -15605,11 +16074,13 @@ var ts; } return result; } - function createInstantiatedSymbolTable(symbols, mapper) { + // The mappingThisOnly flag indicates that the only type parameter being mapped is "this". When the flag is true, + // we check symbols to see if we can quickly conclude they are free of "this" references, thus needing no instantiation. + function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { var result = {}; for (var _i = 0; _i < symbols.length; _i++) { var symbol = symbols[_i]; - result[symbol.name] = instantiateSymbol(symbol, mapper); + result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } return result; } @@ -15640,44 +16111,54 @@ var ts; } return type; } - function resolveClassOrInterfaceMembers(type) { - var target = resolveDeclaredMembers(type); - var members = target.symbol.members; - var callSignatures = target.declaredCallSignatures; - var constructSignatures = target.declaredConstructSignatures; - var stringIndexType = target.declaredStringIndexType; - var numberIndexType = target.declaredNumberIndexType; - var baseTypes = getBaseTypes(target); + function getTypeWithThisArgument(type, thisArgument) { + if (type.flags & 4096 /* Reference */) { + return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + } + return type; + } + function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) { + var mapper = identityMapper; + var members = source.symbol.members; + var callSignatures = source.declaredCallSignatures; + var constructSignatures = source.declaredConstructSignatures; + var stringIndexType = source.declaredStringIndexType; + var numberIndexType = source.declaredNumberIndexType; + if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { + mapper = createTypeMapper(typeParameters, typeArguments); + members = createInstantiatedSymbolTable(source.declaredProperties, mapper, /*mappingThisOnly*/ typeParameters.length === 1); + callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); + constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); + stringIndexType = instantiateType(source.declaredStringIndexType, mapper); + numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); + } + var baseTypes = getBaseTypes(source); if (baseTypes.length) { - members = createSymbolTable(target.declaredProperties); + if (members === source.symbol.members) { + members = createSymbolTable(source.declaredProperties); + } + var thisArgument = ts.lastOrUndefined(typeArguments); for (var _i = 0; _i < baseTypes.length; _i++) { var baseType = baseTypes[_i]; - addInheritedMembers(members, getPropertiesOfObjectType(baseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(baseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(baseType, 1 /* Construct */)); - stringIndexType = stringIndexType || getIndexTypeOfType(baseType, 0 /* String */); - numberIndexType = numberIndexType || getIndexTypeOfType(baseType, 1 /* Number */); + var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; + addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); + stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0 /* String */); + numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1 /* Number */); } } setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } + function resolveClassOrInterfaceMembers(type) { + resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); + } function resolveTypeReferenceMembers(type) { - var target = resolveDeclaredMembers(type.target); - var mapper = createTypeMapper(target.typeParameters, type.typeArguments); - var members = createInstantiatedSymbolTable(target.declaredProperties, mapper); - var callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); - var constructSignatures = instantiateList(target.declaredConstructSignatures, mapper, instantiateSignature); - var stringIndexType = target.declaredStringIndexType ? instantiateType(target.declaredStringIndexType, mapper) : undefined; - var numberIndexType = target.declaredNumberIndexType ? instantiateType(target.declaredNumberIndexType, mapper) : undefined; - ts.forEach(getBaseTypes(target), function (baseType) { - var instantiatedBaseType = instantiateType(baseType, mapper); - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0 /* String */); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1 /* Number */); - }); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var source = resolveDeclaredMembers(type.target); + var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); + var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? + type.typeArguments : ts.concatenate(type.typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); @@ -15726,7 +16207,9 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noSubtypeReduction*/ true))); + var arrayElementType = getUnionType(type.elementTypes, /*noSubtypeReduction*/ true); + // Make the tuple type itself the 'this' type by including an extra type argument + var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -15842,7 +16325,14 @@ var ts; var constructSignatures; var stringIndexType; var numberIndexType; - if (symbol.flags & 2048 /* TypeLiteral */) { + if (type.target) { + members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); + callSignatures = instantiateList(getSignaturesOfType(type.target, 0 /* Call */), type.mapper, instantiateSignature); + constructSignatures = instantiateList(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper, instantiateSignature); + stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0 /* String */), type.mapper); + numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1 /* Number */), type.mapper); + } + else if (symbol.flags & 2048 /* TypeLiteral */) { members = symbol.members; callSignatures = getSignaturesOfSymbol(members["__call"]); constructSignatures = getSignaturesOfSymbol(members["__new"]); @@ -15879,7 +16369,10 @@ var ts; } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & (1024 /* Class */ | 2048 /* Interface */)) { + if (type.flags & 4096 /* Reference */) { + resolveTypeReferenceMembers(type); + } + else if (type.flags & (1024 /* Class */ | 2048 /* Interface */)) { resolveClassOrInterfaceMembers(type); } else if (type.flags & 65536 /* Anonymous */) { @@ -15894,9 +16387,6 @@ var ts; else if (type.flags & 32768 /* Intersection */) { resolveIntersectionTypeMembers(type); } - else { - resolveTypeReferenceMembers(type); - } } return type; } @@ -16125,7 +16615,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 142 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 144 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -16157,7 +16647,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 148 /* TypePredicate */) { + if (declaration.type.kind === 150 /* TypePredicate */) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -16169,8 +16659,8 @@ var ts; else { // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 143 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 144 /* SetAccessor */); + if (declaration.kind === 145 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 146 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -16188,19 +16678,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -16215,6 +16705,16 @@ var ts; } return result; } + function resolveExternalModuleTypeByLiteral(name) { + var moduleSym = resolveExternalModuleName(name, name); + if (moduleSym) { + var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); + if (resolvedModuleSymbol) { + return getTypeOfSymbol(resolvedModuleSymbol); + } + } + return anyType; + } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { @@ -16277,7 +16777,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 142 /* Constructor */ || signature.declaration.kind === 146 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 144 /* Constructor */ || signature.declaration.kind === 148 /* ConstructSignature */; var type = createObjectType(65536 /* Anonymous */ | 262144 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -16291,7 +16791,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 126 /* NumberKeyword */ : 128 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 128 /* NumberKeyword */ : 130 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -16320,30 +16820,33 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 137 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137 /* TypeParameter */).parent); } function getTypeListId(types) { - switch (types.length) { - case 1: - return "" + types[0].id; - case 2: - return types[0].id + "," + types[1].id; - default: - var result = ""; - for (var i = 0; i < types.length; i++) { - if (i > 0) { - result += ","; + if (types) { + switch (types.length) { + case 1: + return "" + types[0].id; + case 2: + return types[0].id + "," + types[1].id; + default: + var result = ""; + for (var i = 0; i < types.length; i++) { + if (i > 0) { + result += ","; + } + result += types[i].id; } - result += types[i].id; - } - return result; + return result; + } } + return ""; } // This function is used to propagate certain flags when creating new object type references and union types. // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type @@ -16361,7 +16864,7 @@ var ts; var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 /* Reference */ | getPropagatingFlagsOfTypes(typeArguments); + var flags = 4096 /* Reference */ | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -16380,13 +16883,13 @@ var ts; currentNode = currentNode.parent; } // if last step was made from the type parameter this means that path has started somewhere in constraint which is illegal - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 137 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 149 /* TypeReference */ && n.typeName.kind === 67 /* Identifier */) { + if (n.kind === 151 /* TypeReference */ && n.typeName.kind === 69 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -16473,7 +16976,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 149 /* TypeReference */ ? node.typeName : + var typeNameOrExpression = node.kind === 151 /* TypeReference */ ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; @@ -16505,9 +17008,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: return declaration; } } @@ -16548,10 +17051,13 @@ var ts; * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type */ function getExportedTypeFromNamespace(namespace, name) { - var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); - var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 /* Type */); + var typeSymbol = getExportedSymbolFromNamespace(namespace, name); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } + function getExportedSymbolFromNamespace(namespace, name) { + var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); + return namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 /* Type */ | 107455 /* Value */); + } function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } @@ -16567,17 +17073,17 @@ var ts; /** * Instantiates a global type that is generic with some element type, and returns that instantiation. */ - function createTypeFromGenericGlobalType(genericGlobalType, elementType) { - return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, [elementType]) : emptyObjectType; + function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { + return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; } function createIterableType(elementType) { - return createTypeFromGenericGlobalType(globalIterableType, elementType); + return createTypeFromGenericGlobalType(globalIterableType, [elementType]); } function createIterableIteratorType(elementType) { - return createTypeFromGenericGlobalType(globalIterableIteratorType, elementType); + return createTypeFromGenericGlobalType(globalIterableIteratorType, [elementType]); } function createArrayType(elementType) { - return createTypeFromGenericGlobalType(globalArrayType, elementType); + return createTypeFromGenericGlobalType(globalArrayType, [elementType]); } function getTypeFromArrayTypeNode(node) { var links = getNodeLinks(node); @@ -16749,48 +17255,68 @@ var ts; } return links.resolvedType; } + function getThisType(node) { + var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); + var parent = container && container.parent; + if (parent && (ts.isClassLike(parent) || parent.kind === 215 /* InterfaceDeclaration */)) { + if (!(container.flags & 128 /* Static */)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; + } + } + error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); + return unknownType; + } + function getTypeFromThisTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getThisType(node); + } + return links.resolvedType; + } function getTypeFromTypeNode(node) { switch (node.kind) { - case 115 /* AnyKeyword */: + case 117 /* AnyKeyword */: return anyType; - case 128 /* StringKeyword */: + case 130 /* StringKeyword */: return stringType; - case 126 /* NumberKeyword */: + case 128 /* NumberKeyword */: return numberType; - case 118 /* BooleanKeyword */: + case 120 /* BooleanKeyword */: return booleanType; - case 129 /* SymbolKeyword */: + case 131 /* SymbolKeyword */: return esSymbolType; - case 101 /* VoidKeyword */: + case 103 /* VoidKeyword */: return voidType; + case 97 /* ThisKeyword */: + return getTypeFromThisTypeNode(node); case 9 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 149 /* TypeReference */: + case 151 /* TypeReference */: return getTypeFromTypeReference(node); - case 148 /* TypePredicate */: + case 150 /* TypePredicate */: return booleanType; - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 154 /* ArrayType */: + case 156 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 155 /* TupleType */: + case 157 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 156 /* UnionType */: + case 158 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 157 /* IntersectionType */: + case 159 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 158 /* ParenthesizedType */: + case 160 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 153 /* TypeLiteral */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 155 /* TypeLiteral */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 67 /* Identifier */: - case 133 /* QualifiedName */: + case 69 /* Identifier */: + case 135 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -16894,7 +17420,7 @@ var ts; type: instantiateType(signature.typePredicate.type, mapper) }; } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -16932,21 +17458,13 @@ var ts; } // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it var result = createObjectType(65536 /* Anonymous */ | 131072 /* Instantiated */, type.symbol); - result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); - result.members = createSymbolTable(result.properties); - result.callSignatures = instantiateList(getSignaturesOfType(type, 0 /* Call */), mapper, instantiateSignature); - result.constructSignatures = instantiateList(getSignaturesOfType(type, 1 /* Construct */), mapper, instantiateSignature); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType) - result.stringIndexType = instantiateType(stringIndexType, mapper); - if (numberIndexType) - result.numberIndexType = instantiateType(numberIndexType, mapper); + result.target = type; + result.mapper = mapper; mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { - if (mapper !== identityMapper) { + if (type && mapper !== identityMapper) { if (type.flags & 512 /* TypeParameter */) { return mapper(type); } @@ -16972,27 +17490,27 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 179 /* BinaryExpression */: - return node.operatorToken.kind === 51 /* BarBarToken */ && + case 181 /* BinaryExpression */: + return node.operatorToken.kind === 52 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 243 /* PropertyAssignment */: + case 245 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -17176,7 +17694,7 @@ var ts; else { if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { // We have type references to same target type, see if relationship holds for all type arguments - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { return result; } } @@ -17205,7 +17723,7 @@ var ts; if (source.flags & 80896 /* ObjectType */ && target.flags & 80896 /* ObjectType */) { if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { // We have type references to same target type, see if all type arguments are identical - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, /*reportErrors*/ false)) { + if (result = typeArgumentsRelatedTo(source, target, /*reportErrors*/ false)) { return result; } } @@ -17322,9 +17840,14 @@ var ts; } return result; } - function typesRelatedTo(sources, targets, reportErrors) { + function typeArgumentsRelatedTo(source, target, reportErrors) { + var sources = source.typeArguments || emptyArray; + var targets = target.typeArguments || emptyArray; + if (sources.length !== targets.length && relation === identityRelation) { + return 0 /* False */; + } var result = -1 /* True */; - for (var i = 0, len = sources.length; i < len; i++) { + for (var i = 0; i < targets.length; i++) { var related = isRelatedTo(sources[i], targets[i], reportErrors); if (!related) { return 0 /* False */; @@ -17542,7 +18065,7 @@ var ts; if (kind === 1 /* Construct */) { // Only want to compare the construct signatures for abstractness guarantees. // Because the "abstractness" of a class is the same across all construct signatures - // (internally we are checking the corresponding declaration), it is enough to perform + // (internally we are checking the corresponding declaration), it is enough to perform // the check and report an error once over all pairs of source and target construct signatures. // // sourceSig and targetSig are (possibly) undefined. @@ -18042,22 +18565,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 136 /* Parameter */: + case 138 /* Parameter */: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -18167,9 +18690,10 @@ var ts; } else if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { // If source and target are references to the same generic type, infer from type arguments - var sourceTypes = source.typeArguments; - var targetTypes = target.typeArguments; - for (var i = 0; i < sourceTypes.length; i++) { + var sourceTypes = source.typeArguments || emptyArray; + var targetTypes = target.typeArguments || emptyArray; + var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; + for (var i = 0; i < count; i++) { inferFromTypes(sourceTypes[i], targetTypes[i]); } } @@ -18347,10 +18871,10 @@ var ts; // The expression is restricted to a single identifier or a sequence of identifiers separated by periods while (node) { switch (node.kind) { - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return true; - case 67 /* Identifier */: - case 133 /* QualifiedName */: + case 69 /* Identifier */: + case 135 /* QualifiedName */: node = node.parent; continue; default: @@ -18396,12 +18920,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 55 /* FirstAssignment */ && node.operatorToken.kind <= 66 /* LastAssignment */) { + if (node.operatorToken.kind >= 56 /* FirstAssignment */ && node.operatorToken.kind <= 68 /* LastAssignment */) { var n = node.left; - while (n.kind === 170 /* ParenthesizedExpression */) { + while (n.kind === 172 /* ParenthesizedExpression */) { n = n.expression; } - if (n.kind === 67 /* Identifier */ && getResolvedSymbol(n) === symbol) { + if (n.kind === 69 /* Identifier */ && getResolvedSymbol(n) === symbol) { return true; } } @@ -18415,55 +18939,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 159 /* ObjectBindingPattern */: - case 160 /* ArrayBindingPattern */: - case 162 /* ArrayLiteralExpression */: - case 163 /* ObjectLiteralExpression */: - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 169 /* TypeAssertionExpression */: - case 187 /* AsExpression */: - case 170 /* ParenthesizedExpression */: - case 177 /* PrefixUnaryExpression */: - case 173 /* DeleteExpression */: - case 176 /* AwaitExpression */: - case 174 /* TypeOfExpression */: - case 175 /* VoidExpression */: - case 178 /* PostfixUnaryExpression */: - case 182 /* YieldExpression */: - case 180 /* ConditionalExpression */: - case 183 /* SpreadElementExpression */: - case 190 /* Block */: - case 191 /* VariableStatement */: - case 193 /* ExpressionStatement */: - case 194 /* IfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 202 /* ReturnStatement */: - case 203 /* WithStatement */: - case 204 /* SwitchStatement */: - case 239 /* CaseClause */: - case 240 /* DefaultClause */: - case 205 /* LabeledStatement */: - case 206 /* ThrowStatement */: - case 207 /* TryStatement */: - case 242 /* CatchClause */: - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - case 236 /* JsxAttribute */: - case 237 /* JsxSpreadAttribute */: - case 233 /* JsxOpeningElement */: - case 238 /* JsxExpression */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + case 164 /* ArrayLiteralExpression */: + case 165 /* ObjectLiteralExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: + case 172 /* ParenthesizedExpression */: + case 179 /* PrefixUnaryExpression */: + case 175 /* DeleteExpression */: + case 178 /* AwaitExpression */: + case 176 /* TypeOfExpression */: + case 177 /* VoidExpression */: + case 180 /* PostfixUnaryExpression */: + case 184 /* YieldExpression */: + case 182 /* ConditionalExpression */: + case 185 /* SpreadElementExpression */: + case 192 /* Block */: + case 193 /* VariableStatement */: + case 195 /* ExpressionStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 204 /* ReturnStatement */: + case 205 /* WithStatement */: + case 206 /* SwitchStatement */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + case 207 /* LabeledStatement */: + case 208 /* ThrowStatement */: + case 209 /* TryStatement */: + case 244 /* CatchClause */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 238 /* JsxAttribute */: + case 239 /* JsxSpreadAttribute */: + case 235 /* JsxOpeningElement */: + case 240 /* JsxExpression */: return ts.forEachChild(node, isAssignedIn); } return false; @@ -18480,37 +19004,37 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 194 /* IfStatement */: + case 196 /* IfStatement */: // In a branch of an if statement, narrow based on controlling expression if (child !== node.expression) { narrowedType = narrowType(type, node.expression, /*assumeTrue*/ child === node.thenStatement); } break; - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: // In a branch of a conditional expression, narrow based on controlling condition if (child !== node.condition) { narrowedType = narrowType(type, node.condition, /*assumeTrue*/ child === node.whenTrue); } break; - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node.right) { - if (node.operatorToken.kind === 50 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 51 /* AmpersandAmpersandToken */) { narrowedType = narrowType(type, node.left, /*assumeTrue*/ true); } - else if (node.operatorToken.kind === 51 /* BarBarToken */) { + else if (node.operatorToken.kind === 52 /* BarBarToken */) { narrowedType = narrowType(type, node.left, /*assumeTrue*/ false); } } break; - case 246 /* SourceFile */: - case 216 /* ModuleDeclaration */: - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 142 /* Constructor */: + case 248 /* SourceFile */: + case 218 /* ModuleDeclaration */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: // Stop at the first containing function or module declaration break loop; } @@ -18527,12 +19051,12 @@ var ts; return type; function narrowTypeByEquality(type, expr, assumeTrue) { // Check that we have 'typeof ' on the left and string literal on the right - if (expr.left.kind !== 174 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { + if (expr.left.kind !== 176 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 67 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 69 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; @@ -18592,7 +19116,7 @@ var ts; } function narrowTypeByInstanceof(type, expr, assumeTrue) { // Check that type is not any, assumed result is true, and we have variable symbol on the left - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 69 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { return type; } // Check that right operand is a function type with a prototype property @@ -18664,27 +19188,27 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 166 /* CallExpression */: + case 168 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: var operator = expr.operatorToken.kind; if (operator === 32 /* EqualsEqualsEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 50 /* AmpersandAmpersandToken */) { + else if (operator === 51 /* AmpersandAmpersandToken */) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 51 /* BarBarToken */) { + else if (operator === 52 /* BarBarToken */) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 89 /* InstanceOfKeyword */) { + else if (operator === 91 /* InstanceOfKeyword */) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 177 /* PrefixUnaryExpression */: - if (expr.operator === 48 /* ExclamationToken */) { + case 179 /* PrefixUnaryExpression */: + if (expr.operator === 49 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -18702,7 +19226,7 @@ var ts; // can explicitly bound arguments objects if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 172 /* ArrowFunction */) { + if (container.kind === 174 /* ArrowFunction */) { if (languageVersion < 2 /* ES6 */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -18733,7 +19257,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & 2 /* BlockScopedVariable */) === 0 || - symbol.valueDeclaration.parent.kind === 242 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 244 /* CatchClause */) { return; } // - check if binding is used in some function @@ -18742,12 +19266,12 @@ var ts; // nesting structure: // (variable declaration or binding element) -> variable declaration list -> container var container = symbol.valueDeclaration; - while (container.kind !== 210 /* VariableDeclarationList */) { + while (container.kind !== 212 /* VariableDeclarationList */) { container = container.parent; } // get the parent of variable declaration list container = container.parent; - if (container.kind === 191 /* VariableStatement */) { + if (container.kind === 193 /* VariableStatement */) { // if parent is variable statement - get its parent container = container.parent; } @@ -18767,7 +19291,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 139 /* PropertyDeclaration */ || container.kind === 142 /* Constructor */) { + if (container.kind === 141 /* PropertyDeclaration */ || container.kind === 144 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -18781,32 +19305,32 @@ var ts; var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 172 /* ArrowFunction */) { + if (container.kind === 174 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); } switch (container.kind) { - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 142 /* Constructor */: + case 144 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -18815,35 +19339,35 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); + return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } return anyType; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 136 /* Parameter */) { + if (n.kind === 138 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 168 /* CallExpression */ && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; var container = ts.getSuperContainer(node, /*includeFunctions*/ true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting - while (container && container.kind === 172 /* ArrowFunction */) { + // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting + while (container && container.kind === 174 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*includeFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; } } var canUseSuperExpression = isLegalUsageOfSuperExpression(container); var nodeCheckFlag = 0; - // always set NodeCheckFlags for 'super' expression node + // always set NodeCheckFlags for 'super' expression node if (canUseSuperExpression) { if ((container.flags & 128 /* Static */) || isCallExpression) { nodeCheckFlag = 512 /* SuperStatic */; @@ -18866,7 +19390,7 @@ var ts; return unknownType; } if (!canUseSuperExpression) { - if (container && container.kind === 134 /* ComputedPropertyName */) { + if (container && container.kind === 136 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -18877,7 +19401,7 @@ var ts; } return unknownType; } - if (container.kind === 142 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 144 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; @@ -18892,7 +19416,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 142 /* Constructor */; + return container.kind === 144 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -18902,19 +19426,19 @@ var ts; // topmost container must be something that is directly nested in the class declaration if (container && ts.isClassLike(container.parent)) { if (container.flags & 128 /* Static */) { - return container.kind === 141 /* MethodDeclaration */ || - container.kind === 140 /* MethodSignature */ || - container.kind === 143 /* GetAccessor */ || - container.kind === 144 /* SetAccessor */; + return container.kind === 143 /* MethodDeclaration */ || + container.kind === 142 /* MethodSignature */ || + container.kind === 145 /* GetAccessor */ || + container.kind === 146 /* SetAccessor */; } else { - return container.kind === 141 /* MethodDeclaration */ || - container.kind === 140 /* MethodSignature */ || - container.kind === 143 /* GetAccessor */ || - container.kind === 144 /* SetAccessor */ || - container.kind === 139 /* PropertyDeclaration */ || - container.kind === 138 /* PropertySignature */ || - container.kind === 142 /* Constructor */; + return container.kind === 143 /* MethodDeclaration */ || + container.kind === 142 /* MethodSignature */ || + container.kind === 145 /* GetAccessor */ || + container.kind === 146 /* SetAccessor */ || + container.kind === 141 /* PropertyDeclaration */ || + container.kind === 140 /* PropertySignature */ || + container.kind === 144 /* Constructor */; } } } @@ -18955,7 +19479,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 136 /* Parameter */) { + if (declaration.kind === 138 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -18988,7 +19512,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 136 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 138 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -18999,8 +19523,8 @@ var ts; // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 142 /* Constructor */ || - functionDecl.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144 /* SetAccessor */))) { + functionDecl.kind === 144 /* Constructor */ || + functionDecl.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -19022,7 +19546,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 168 /* TaggedTemplateExpression */) { + if (template.parent.kind === 170 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -19030,13 +19554,13 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) { + if (operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { // In an assignment expression, the right operand is contextually typed by the type of the left operand. if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 51 /* BarBarToken */) { + else if (operator === 52 /* BarBarToken */) { // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand. var type = getContextualType(binaryExpression); @@ -19143,7 +19667,7 @@ var ts; } function getContextualTypeForJsxExpression(expr) { // Contextual type only applies to JSX expressions that are in attribute assignments (not in 'Children' positions) - if (expr.parent.kind === 236 /* JsxAttribute */) { + if (expr.parent.kind === 238 /* JsxAttribute */) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -19153,7 +19677,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 237 /* JsxSpreadAttribute */) { + if (expr.kind === 239 /* JsxSpreadAttribute */) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -19174,38 +19698,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 209 /* VariableDeclaration */: - case 136 /* Parameter */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 163 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 172 /* ArrowFunction */: - case 202 /* ReturnStatement */: + case 174 /* ArrowFunction */: + case 204 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 182 /* YieldExpression */: + case 184 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 169 /* TypeAssertionExpression */: - case 187 /* AsExpression */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 243 /* PropertyAssignment */: + case 245 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 188 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 181 /* TemplateExpression */); + case 190 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 183 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return getContextualType(parent); - case 238 /* JsxExpression */: - case 237 /* JsxSpreadAttribute */: + case 240 /* JsxExpression */: + case 239 /* JsxSpreadAttribute */: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -19222,7 +19746,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 171 /* FunctionExpression */ || node.kind === 172 /* ArrowFunction */; + return node.kind === 173 /* FunctionExpression */ || node.kind === 174 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -19236,7 +19760,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -19299,13 +19823,13 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 179 /* BinaryExpression */ && parent.operatorToken.kind === 55 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 181 /* BinaryExpression */ && parent.operatorToken.kind === 56 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 243 /* PropertyAssignment */) { + if (parent.kind === 245 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 162 /* ArrayLiteralExpression */) { + if (parent.kind === 164 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -19321,8 +19845,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function hasDefaultValue(node) { - return (node.kind === 161 /* BindingElement */ && !!node.initializer) || - (node.kind === 179 /* BinaryExpression */ && node.operatorToken.kind === 55 /* EqualsToken */); + return (node.kind === 163 /* BindingElement */ && !!node.initializer) || + (node.kind === 181 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -19331,7 +19855,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 183 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 185 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -19355,7 +19879,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 183 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 185 /* SpreadElementExpression */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -19370,7 +19894,7 @@ var ts; var pattern = contextualType.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. - if (pattern && (pattern.kind === 160 /* ArrayBindingPattern */ || pattern.kind === 162 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 162 /* ArrayBindingPattern */ || pattern.kind === 164 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -19378,7 +19902,7 @@ var ts; elementTypes.push(contextualType.elementTypes[i]); } else { - if (patternElement.kind !== 185 /* OmittedExpression */) { + if (patternElement.kind !== 187 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -19393,7 +19917,7 @@ var ts; return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 134 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 136 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, @@ -19443,30 +19967,30 @@ var ts; return links.resolvedType; } function checkObjectLiteral(node, contextualMapper) { + var inDestructuringPattern = isAssignmentTarget(node); // Grammar checking - checkGrammarObjectLiteralExpression(node); + checkGrammarObjectLiteralExpression(node, inDestructuringPattern); var propertiesTable = {}; var propertiesArray = []; var contextualType = getContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 159 /* ObjectBindingPattern */ || contextualType.pattern.kind === 163 /* ObjectLiteralExpression */); - var inDestructuringPattern = isAssignmentTarget(node); + (contextualType.pattern.kind === 161 /* ObjectBindingPattern */ || contextualType.pattern.kind === 165 /* ObjectLiteralExpression */); var typeFlags = 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 243 /* PropertyAssignment */ || - memberDecl.kind === 244 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 245 /* PropertyAssignment */ || + memberDecl.kind === 246 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 243 /* PropertyAssignment */) { + if (memberDecl.kind === 245 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 141 /* MethodDeclaration */) { + else if (memberDecl.kind === 143 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 244 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 246 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -19474,7 +19998,9 @@ var ts; if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - if (memberDecl.kind === 243 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) { + var isOptional = (memberDecl.kind === 245 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 246 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + if (isOptional) { prop.flags |= 536870912 /* Optional */; } } @@ -19504,7 +20030,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 143 /* GetAccessor */ || memberDecl.kind === 144 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 145 /* GetAccessor */ || memberDecl.kind === 146 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -19566,7 +20092,7 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 67 /* Identifier */) { + if (lhs.kind === 69 /* Identifier */) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && @@ -19587,18 +20113,18 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 238 /* JsxExpression */: + case 240 /* JsxExpression */: checkJsxExpression(child); break; - case 231 /* JsxElement */: + case 233 /* JsxElement */: checkJsxElement(child); break; - case 232 /* JsxSelfClosingElement */: + case 234 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; default: // No checks for JSX Text - ts.Debug.assert(child.kind === 234 /* JsxText */); + ts.Debug.assert(child.kind === 236 /* JsxText */); } } return jsxElementType || anyType; @@ -19614,7 +20140,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 133 /* QualifiedName */) { + if (tagName.kind === 135 /* QualifiedName */) { return false; } else { @@ -19733,12 +20259,14 @@ var ts; // Look up the value in the current scope if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4 /* ClassElement */; - getSymbolLinks(valueSymbol).referenced = true; + if (valueSymbol.flags & 8388608 /* Alias */) { + markAliasSymbolAsReferenced(valueSymbol); + } } return valueSymbol || unknownSymbol; } function resolveJsxTagName(node) { - if (node.tagName.kind === 67 /* Identifier */) { + if (node.tagName.kind === 69 /* Identifier */) { var tag = node.tagName; var sym = getResolvedSymbol(tag); return sym.exportSymbol || sym; @@ -19923,11 +20451,11 @@ var ts; // thus should have their types ignored var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 236 /* JsxAttribute */) { + if (node.attributes[i].kind === 238 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 237 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 239 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -19957,7 +20485,7 @@ var ts; // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 139 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 141 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; @@ -19973,8 +20501,8 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 93 /* SuperKeyword */) { - var errorNode = node.kind === 164 /* PropertyAccessExpression */ ? + if (left.kind === 95 /* SuperKeyword */) { + var errorNode = node.kind === 166 /* PropertyAccessExpression */ ? node.name : node.right; // TS 1.0 spec (April 2014): 4.8.2 @@ -19984,7 +20512,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (getDeclarationKindFromSymbol(prop) !== 141 /* MethodDeclaration */) { + if (getDeclarationKindFromSymbol(prop) !== 143 /* MethodDeclaration */) { // `prop` refers to a *property* declared in the super class // rather than a *method*, so it does not satisfy the above criteria. error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -20017,7 +20545,7 @@ var ts; } // Property is known to be protected at this point // All protected properties of a supertype are accessible in a super access - if (left.kind === 93 /* SuperKeyword */) { + if (left.kind === 95 /* SuperKeyword */) { return true; } // A protected property is accessible in the declaring class and classes derived from it @@ -20030,6 +20558,10 @@ var ts; return true; } // An instance property must be accessed through an instance of the enclosing class + if (type.flags & 33554432 /* ThisType */) { + // get the original type -- represented as the type constraint of the 'this' type + type = getConstraintOfTypeParameter(type); + } // TODO: why is the first part of this check here? if (!(getTargetType(type).flags & (1024 /* Class */ | 2048 /* Interface */) && hasBaseType(type, enclosingClass))) { error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); @@ -20056,18 +20588,18 @@ var ts; var prop = getPropertyOfType(apparentType, right.text); if (!prop) { if (right.text) { - error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type)); + error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type.flags & 33554432 /* ThisType */ ? apparentType : type)); } return unknownType; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32 /* Class */) { - checkClassPropertyAccess(node, left, type, prop); + checkClassPropertyAccess(node, left, apparentType, prop); } return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 164 /* PropertyAccessExpression */ + var left = node.kind === 166 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -20083,7 +20615,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 167 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 169 /* NewExpression */ && 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); @@ -20155,6 +20687,7 @@ var ts; } /** * If indexArgumentExpression is a string literal or number literal, returns its text. + * If indexArgumentExpression is a constant value, returns its string value. * If indexArgumentExpression is a well known symbol, returns the property name corresponding * to this symbol, as long as it is a proper symbol reference. * Otherwise, returns undefined. @@ -20163,6 +20696,12 @@ var ts; if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { return indexArgumentExpression.text; } + if (indexArgumentExpression.kind === 167 /* ElementAccessExpression */ || indexArgumentExpression.kind === 166 /* PropertyAccessExpression */) { + var value = getConstantValue(indexArgumentExpression); + if (value !== undefined) { + return value.toString(); + } + } if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) { var rightHandSideName = indexArgumentExpression.name.text; return ts.getPropertyNameForKnownSymbolName(rightHandSideName); @@ -20212,10 +20751,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 168 /* TaggedTemplateExpression */) { + if (node.kind === 170 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 137 /* Decorator */) { + else if (node.kind !== 139 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -20281,7 +20820,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 183 /* SpreadElementExpression */) { + if (arg && arg.kind === 185 /* SpreadElementExpression */) { return i; } } @@ -20293,13 +20832,13 @@ var ts; var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments var isDecorator; var spreadArgIndex = -1; - if (node.kind === 168 /* TaggedTemplateExpression */) { + if (node.kind === 170 /* TaggedTemplateExpression */) { var tagExpression = node; // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 181 /* TemplateExpression */) { + if (tagExpression.template.kind === 183 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var templateExpression = tagExpression.template; @@ -20316,7 +20855,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 137 /* Decorator */) { + else if (node.kind === 139 /* Decorator */) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); @@ -20325,7 +20864,7 @@ var ts; var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 167 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 169 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -20404,7 +20943,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 187 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type @@ -20463,7 +21002,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 187 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); @@ -20495,16 +21034,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 168 /* TaggedTemplateExpression */) { + if (node.kind === 170 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 181 /* TemplateExpression */) { + if (template.kind === 183 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 137 /* Decorator */) { + else if (node.kind === 139 /* Decorator */) { // For a decorator, we return undefined as we will determine // the number and types of arguments for a decorator using // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. @@ -20529,25 +21068,29 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 137 /* Decorator */) { + if (node.kind === 139 /* Decorator */) { switch (node.parent.kind) { - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts) + // If we are emitting decorators for ES3, we will only pass two arguments. + if (languageVersion === 0 /* ES3 */) { + return 2; + } // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 136 /* Parameter */: + case 138 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -20572,25 +21115,25 @@ var ts; function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. switch (node.kind) { - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 136 /* Parameter */: + case 138 /* Parameter */: // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 142 /* Constructor */) { + if (node.kind === 144 /* Constructor */) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } // fall-through - case 139 /* PropertyDeclaration */: - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: // For a property or method decorator, the `target` is the // "static"-side type of the parent of the member if the member is // declared "static"; otherwise, it is the "instance"-side type of the @@ -20619,33 +21162,33 @@ var ts; function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 136 /* Parameter */: + case 138 /* Parameter */: node = node.parent; - if (node.kind === 142 /* Constructor */) { + if (node.kind === 144 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } // For a non-constructor parameter decorator, the `propertyKey` will be either // a string or a symbol, based on the name of the parameter's containing method. // fall-through - case 139 /* PropertyDeclaration */: - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: // The `propertyKey` for a property or method decorator will be a // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will // be either string or symbol. var element = node; switch (element.name.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return getStringLiteralType(element.name); - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) { return nameType; @@ -20673,18 +21216,18 @@ var ts; // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a paramter decorator switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 136 /* Parameter */: + case 138 /* Parameter */: // The `parameterIndex` for a parameter decorator is always a number return numberType; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -20717,10 +21260,10 @@ var ts; // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors - if (node.kind === 137 /* Decorator */) { + if (node.kind === 139 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */) { return globalTemplateStringsArrayType; } // This is not a synthetic argument, so we return 'undefined' @@ -20732,8 +21275,8 @@ var ts; */ function getEffectiveArgument(node, args, argIndex) { // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 137 /* Decorator */ || - (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */)) { + if (node.kind === 139 /* Decorator */ || + (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -20742,11 +21285,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 137 /* Decorator */) { + if (node.kind === 139 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -20755,13 +21298,13 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 168 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 137 /* Decorator */; + var isTaggedTemplate = node.kind === 170 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 139 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (node.expression.kind !== 93 /* SuperKeyword */) { + if (node.expression.kind !== 95 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -20968,7 +21511,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 93 /* SuperKeyword */) { + if (node.expression.kind === 95 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated @@ -21101,16 +21644,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 136 /* Parameter */: + case 138 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -21147,16 +21690,16 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 166 /* CallExpression */) { + if (node.kind === 168 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 167 /* NewExpression */) { + else if (node.kind === 169 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 168 /* TaggedTemplateExpression */) { + else if (node.kind === 170 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 137 /* Decorator */) { + else if (node.kind === 139 /* Decorator */) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -21174,15 +21717,15 @@ var ts; // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 93 /* SuperKeyword */) { + if (node.expression.kind === 95 /* SuperKeyword */) { return voidType; } - if (node.kind === 167 /* NewExpression */) { + if (node.kind === 169 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 142 /* Constructor */ && - declaration.kind !== 146 /* ConstructSignature */ && - declaration.kind !== 151 /* ConstructorType */) { + declaration.kind !== 144 /* Constructor */ && + declaration.kind !== 148 /* ConstructSignature */ && + declaration.kind !== 153 /* ConstructorType */) { // When resolved signature is a call signature (and not a construct signature) the result type is any if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); @@ -21190,6 +21733,10 @@ var ts; return anyType; } } + // In JavaScript files, calls to any identifier 'require' are treated as external module imports + if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node)) { + return resolveExternalModuleTypeByLiteral(node.arguments[0]); + } return getReturnTypeOfSignature(signature); } function checkTaggedTemplateExpression(node) { @@ -21224,10 +21771,24 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } } + // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push + // the destructured type into the contained binding elements. + function assignBindingElementTypes(node) { + if (ts.isBindingPattern(node.name)) { + for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 187 /* OmittedExpression */) { + getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); + assignBindingElementTypes(element); + } + } + } + } function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { var links = getSymbolLinks(parameter); if (!links.type) { links.type = instantiateType(contextualType, mapper); + assignBindingElementTypes(parameter.valueDeclaration); } else if (isInferentialContext(mapper)) { // Even if the parameter already has a type, it might be because it was given a type while @@ -21279,7 +21840,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 190 /* Block */) { + if (func.body.kind !== 192 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -21398,7 +21959,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 206 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 208 /* ThrowStatement */); } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type @@ -21413,7 +21974,7 @@ var ts; return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 190 /* Block */) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192 /* Block */) { return; } var bodyBlock = func.body; @@ -21431,10 +21992,10 @@ 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 !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 171 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 173 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -21477,14 +22038,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -21506,7 +22067,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 190 /* Block */) { + if (node.body.kind === 192 /* Block */) { checkSourceElement(node.body); } else { @@ -21552,24 +22113,24 @@ var ts; // and property accesses(section 4.10). // All other expression constructs described in this chapter are classified as values. switch (n.kind) { - case 67 /* Identifier */: { + case 69 /* Identifier */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.3 // An identifier expression that references a variable or parameter is classified as a reference. // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; } - case 164 /* PropertyAccessExpression */: { + case 166 /* PropertyAccessExpression */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.10 // A property access expression is always classified as a reference. // NOTE (not in spec): assignment to enum members should not be allowed return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; } - case 165 /* ElementAccessExpression */: - // old compiler doesn't check indexed assess + case 167 /* ElementAccessExpression */: + // old compiler doesn't check indexed access return true; - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -21577,12 +22138,12 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 67 /* Identifier */: - case 164 /* PropertyAccessExpression */: { + case 69 /* Identifier */: + case 166 /* PropertyAccessExpression */: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768 /* Const */) !== 0; } - case 165 /* ElementAccessExpression */: { + case 167 /* ElementAccessExpression */: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 9 /* StringLiteral */) { @@ -21592,7 +22153,7 @@ var ts; } return false; } - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -21638,15 +22199,15 @@ var ts; switch (node.operator) { case 35 /* PlusToken */: case 36 /* MinusToken */: - case 49 /* TildeToken */: + case 50 /* TildeToken */: if (someConstituentTypeHasKind(operandType, 16777216 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 48 /* ExclamationToken */: + case 49 /* ExclamationToken */: return booleanType; - case 40 /* PlusPlusToken */: - case 41 /* MinusMinusToken */: + case 41 /* PlusPlusToken */: + case 42 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -21706,31 +22267,31 @@ var ts; function isConstEnumSymbol(symbol) { return (symbol.flags & 128 /* ConstEnum */) !== 0; } - function checkInstanceOfExpression(node, leftType, rightType) { + function checkInstanceOfExpression(left, right, leftType, rightType) { // TypeScript 1.0 spec (April 2014): 4.15.4 // The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type, // and the right operand to be of type Any or a subtype of the 'Function' interface type. // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported if (allConstituentTypesHaveKind(leftType, 16777726 /* Primitive */)) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); + error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; } - function checkInExpression(node, leftType, rightType) { + function checkInExpression(left, right, leftType, rightType) { // TypeScript 1.0 spec (April 2014): 4.15.5 // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); + error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } @@ -21738,7 +22299,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) { + if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var name_13 = p.name; var type = isTypeAny(sourceType) @@ -21747,7 +22308,12 @@ var ts; isNumericLiteralName(name_13.text) && getIndexTypeOfType(sourceType, 1 /* Number */) || getIndexTypeOfType(sourceType, 0 /* String */); if (type) { - checkDestructuringAssignment(p.initializer || name_13, type); + if (p.kind === 246 /* ShorthandPropertyAssignment */) { + checkDestructuringAssignment(p, type); + } + else { + checkDestructuringAssignment(p.initializer || name_13, type); + } } else { error(name_13, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_13)); @@ -21767,8 +22333,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 185 /* OmittedExpression */) { - if (e.kind !== 183 /* SpreadElementExpression */) { + if (e.kind !== 187 /* OmittedExpression */) { + if (e.kind !== 185 /* SpreadElementExpression */) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -21793,7 +22359,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 179 /* BinaryExpression */ && restExpression.operatorToken.kind === 55 /* EqualsToken */) { + if (restExpression.kind === 181 /* BinaryExpression */ && restExpression.operatorToken.kind === 56 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -21805,15 +22371,26 @@ var ts; } return sourceType; } - function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) { + function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { + var target; + if (exprOrAssignment.kind === 246 /* ShorthandPropertyAssignment */) { + var prop = exprOrAssignment; + if (prop.objectAssignmentInitializer) { + checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); + } + target = exprOrAssignment.name; + } + else { + target = exprOrAssignment; + } + if (target.kind === 181 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 163 /* ObjectLiteralExpression */) { + if (target.kind === 165 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 162 /* ArrayLiteralExpression */) { + if (target.kind === 164 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -21826,34 +22403,39 @@ var ts; return sourceType; } function checkBinaryExpression(node, contextualMapper) { - var operator = node.operatorToken.kind; - if (operator === 55 /* EqualsToken */ && (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); + return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); + } + function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { + var operator = operatorToken.kind; + if (operator === 56 /* EqualsToken */ && (left.kind === 165 /* ObjectLiteralExpression */ || left.kind === 164 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } - var leftType = checkExpression(node.left, contextualMapper); - var rightType = checkExpression(node.right, contextualMapper); + var leftType = checkExpression(left, contextualMapper); + var rightType = checkExpression(right, contextualMapper); switch (operator) { case 37 /* AsteriskToken */: - case 58 /* AsteriskEqualsToken */: - case 38 /* SlashToken */: - case 59 /* SlashEqualsToken */: - case 39 /* PercentToken */: - case 60 /* PercentEqualsToken */: + case 38 /* AsteriskAsteriskToken */: + case 59 /* AsteriskEqualsToken */: + case 60 /* AsteriskAsteriskEqualsToken */: + case 39 /* SlashToken */: + case 61 /* SlashEqualsToken */: + case 40 /* PercentToken */: + case 62 /* PercentEqualsToken */: case 36 /* MinusToken */: - case 57 /* MinusEqualsToken */: - case 42 /* LessThanLessThanToken */: - case 61 /* LessThanLessThanEqualsToken */: - case 43 /* GreaterThanGreaterThanToken */: - case 62 /* GreaterThanGreaterThanEqualsToken */: - case 44 /* GreaterThanGreaterThanGreaterThanToken */: - case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 46 /* BarToken */: - case 65 /* BarEqualsToken */: - case 47 /* CaretToken */: - case 66 /* CaretEqualsToken */: - case 45 /* AmpersandToken */: - case 64 /* AmpersandEqualsToken */: - // TypeScript 1.0 spec (April 2014): 4.15.1 + case 58 /* MinusEqualsToken */: + case 43 /* LessThanLessThanToken */: + case 63 /* LessThanLessThanEqualsToken */: + case 44 /* GreaterThanGreaterThanToken */: + case 64 /* GreaterThanGreaterThanEqualsToken */: + case 45 /* GreaterThanGreaterThanGreaterThanToken */: + case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 47 /* BarToken */: + case 67 /* BarEqualsToken */: + case 48 /* CaretToken */: + case 68 /* CaretEqualsToken */: + case 46 /* AmpersandToken */: + case 66 /* AmpersandEqualsToken */: + // TypeScript 1.0 spec (April 2014): 4.19.1 // These operators require their operands to be of type Any, the Number primitive type, // or an enum type. Operands of an enum type are treated // as having the primitive type Number. If one operand is the null or undefined value, @@ -21868,21 +22450,21 @@ var ts; // try and return them a helpful suggestion if ((leftType.flags & 8 /* Boolean */) && (rightType.flags & 8 /* Boolean */) && - (suggestedOperator = getSuggestedBooleanOperator(node.operatorToken.kind)) !== undefined) { - error(node, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(node.operatorToken.kind), ts.tokenToString(suggestedOperator)); + (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { + error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); } else { // otherwise just check each operand separately and report errors as normal - var leftOk = checkArithmeticOperandType(node.left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(node.right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); if (leftOk && rightOk) { checkAssignmentOperator(numberType); } } return numberType; case 35 /* PlusToken */: - case 56 /* PlusEqualsToken */: - // TypeScript 1.0 spec (April 2014): 4.15.2 + case 57 /* PlusEqualsToken */: + // TypeScript 1.0 spec (April 2014): 4.19.2 // The binary + operator requires both operands to be of the Number primitive type or an enum type, // or at least one of the operands to be of type Any or the String primitive type. // If one operand is the null or undefined value, it is treated as having the type of the other operand. @@ -21915,7 +22497,7 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 56 /* PlusEqualsToken */) { + if (operator === 57 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; @@ -21935,15 +22517,15 @@ var ts; reportOperatorError(); } return booleanType; - case 89 /* InstanceOfKeyword */: - return checkInstanceOfExpression(node, leftType, rightType); - case 88 /* InKeyword */: - return checkInExpression(node, leftType, rightType); - case 50 /* AmpersandAmpersandToken */: + case 91 /* InstanceOfKeyword */: + return checkInstanceOfExpression(left, right, leftType, rightType); + case 90 /* InKeyword */: + return checkInExpression(left, right, leftType, rightType); + case 51 /* AmpersandAmpersandToken */: return rightType; - case 51 /* BarBarToken */: + case 52 /* BarBarToken */: return getUnionType([leftType, rightType]); - case 55 /* EqualsToken */: + case 56 /* EqualsToken */: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); case 24 /* CommaToken */: @@ -21951,8 +22533,8 @@ var ts; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? node.left : - someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? left : + someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -21962,37 +22544,37 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 46 /* BarToken */: - case 65 /* BarEqualsToken */: - return 51 /* BarBarToken */; - case 47 /* CaretToken */: - case 66 /* CaretEqualsToken */: + case 47 /* BarToken */: + case 67 /* BarEqualsToken */: + return 52 /* BarBarToken */; + case 48 /* CaretToken */: + case 68 /* CaretEqualsToken */: return 33 /* ExclamationEqualsEqualsToken */; - case 45 /* AmpersandToken */: - case 64 /* AmpersandEqualsToken */: - return 50 /* AmpersandAmpersandToken */; + case 46 /* AmpersandToken */: + case 66 /* AmpersandEqualsToken */: + return 51 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) { + if (produceDiagnostics && operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { // TypeScript 1.0 spec (April 2014): 4.17 // An assignment of the form // VarExpr = ValueExpr // requires VarExpr to be classified as a reference // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) // and the type of the non - compound operation to be assignable to the type of VarExpr. - 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); + var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); // Use default messages if (ok) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, node.left, /*headMessage*/ undefined); + checkTypeAssignableTo(valueType, leftType, left, /*headMessage*/ undefined); } } } function reportOperatorError() { - error(node, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(node.operatorToken.kind), typeToString(leftType), typeToString(rightType)); + error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); } } function isYieldExpressionInClass(node) { @@ -22083,7 +22665,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 134 /* ComputedPropertyName */) { + if (node.name.kind === 136 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -22094,7 +22676,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 134 /* ComputedPropertyName */) { + if (node.name.kind === 136 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -22124,7 +22706,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 133 /* QualifiedName */) { + if (node.kind === 135 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -22136,9 +22718,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */) && 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); } @@ -22152,78 +22734,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: return checkIdentifier(node); - case 95 /* ThisKeyword */: + case 97 /* ThisKeyword */: return checkThisExpression(node); - case 93 /* SuperKeyword */: + case 95 /* SuperKeyword */: return checkSuperExpression(node); - case 91 /* NullKeyword */: + case 93 /* NullKeyword */: return nullType; - case 97 /* TrueKeyword */: - case 82 /* FalseKeyword */: + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: return booleanType; case 8 /* NumericLiteral */: return checkNumericLiteral(node); - case 181 /* TemplateExpression */: + case 183 /* TemplateExpression */: return checkTemplateExpression(node); case 9 /* StringLiteral */: case 11 /* NoSubstitutionTemplateLiteral */: return stringType; case 10 /* RegularExpressionLiteral */: return globalRegExpType; - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 164 /* PropertyAccessExpression */: + case 166 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 165 /* ElementAccessExpression */: + case 167 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: return checkCallExpression(node); - case 168 /* TaggedTemplateExpression */: + case 170 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 184 /* ClassExpression */: + case 186 /* ClassExpression */: return checkClassExpression(node); - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 174 /* TypeOfExpression */: + case 176 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 169 /* TypeAssertionExpression */: - case 187 /* AsExpression */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: return checkAssertion(node); - case 173 /* DeleteExpression */: + case 175 /* DeleteExpression */: return checkDeleteExpression(node); - case 175 /* VoidExpression */: + case 177 /* VoidExpression */: return checkVoidExpression(node); - case 176 /* AwaitExpression */: + case 178 /* AwaitExpression */: return checkAwaitExpression(node); - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 178 /* PostfixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 183 /* SpreadElementExpression */: + case 185 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 185 /* OmittedExpression */: + case 187 /* OmittedExpression */: return undefinedType; - case 182 /* YieldExpression */: + case 184 /* YieldExpression */: return checkYieldExpression(node); - case 238 /* JsxExpression */: + case 240 /* JsxExpression */: return checkJsxExpression(node); - case 231 /* JsxElement */: + case 233 /* JsxElement */: return checkJsxElement(node); - case 232 /* JsxSelfClosingElement */: + case 234 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 233 /* JsxOpeningElement */: + case 235 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -22252,7 +22834,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 142 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 144 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -22269,15 +22851,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 141 /* MethodDeclaration */ || - node.kind === 211 /* FunctionDeclaration */ || - node.kind === 171 /* FunctionExpression */; + return node.kind === 143 /* MethodDeclaration */ || + node.kind === 213 /* FunctionDeclaration */ || + node.kind === 173 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 67 /* Identifier */ && + if (param.name.kind === 69 /* Identifier */ && param.name.text === parameter.text) { return i; } @@ -22287,31 +22869,31 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { - case 172 /* ArrowFunction */: - case 145 /* CallSignature */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 150 /* FunctionType */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 174 /* ArrowFunction */: + case 147 /* CallSignature */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 152 /* FunctionType */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 147 /* IndexSignature */) { + if (node.kind === 149 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 150 /* FunctionType */ || node.kind === 211 /* FunctionDeclaration */ || node.kind === 151 /* ConstructorType */ || - node.kind === 145 /* CallSignature */ || node.kind === 142 /* Constructor */ || - node.kind === 146 /* ConstructSignature */) { + else if (node.kind === 152 /* FunctionType */ || node.kind === 213 /* FunctionDeclaration */ || node.kind === 153 /* ConstructorType */ || + node.kind === 147 /* CallSignature */ || node.kind === 144 /* Constructor */ || + node.kind === 148 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 148 /* TypePredicate */) { + if (node.type.kind === 150 /* TypePredicate */) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -22330,19 +22912,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 159 /* ObjectBindingPattern */ || - param.name.kind === 160 /* ArrayBindingPattern */) { + if (param.name.kind === 161 /* ObjectBindingPattern */ || + param.name.kind === 162 /* ArrayBindingPattern */) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 67 /* Identifier */ && + if (element.name.kind === 69 /* Identifier */ && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 160 /* ArrayBindingPattern */ || - element.name.kind === 159 /* ObjectBindingPattern */) { + else if (element.name.kind === 162 /* ArrayBindingPattern */ || + element.name.kind === 161 /* ObjectBindingPattern */) { checkBindingPattern(element.name); } } @@ -22366,10 +22948,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 146 /* ConstructSignature */: + case 148 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 145 /* CallSignature */: + case 147 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -22397,7 +22979,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 213 /* InterfaceDeclaration */) { + if (node.kind === 215 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -22417,7 +22999,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 128 /* StringKeyword */: + case 130 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -22425,7 +23007,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 126 /* NumberKeyword */: + case 128 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -22474,7 +23056,7 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 166 /* CallExpression */ && n.expression.kind === 93 /* SuperKeyword */; + return n.kind === 168 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; } function containsSuperCallAsComputedPropertyName(n) { return n.name && containsSuperCall(n.name); @@ -22492,15 +23074,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 95 /* ThisKeyword */) { + if (n.kind === 97 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 171 /* FunctionExpression */ && n.kind !== 211 /* FunctionDeclaration */) { + else if (n.kind !== 173 /* FunctionExpression */ && n.kind !== 213 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 139 /* PropertyDeclaration */ && + return n.kind === 141 /* PropertyDeclaration */ && !(n.flags & 128 /* Static */) && !!n.initializer; } @@ -22530,7 +23112,7 @@ var ts; var superCallStatement; for (var _i = 0; _i < statements.length; _i++) { var statement = statements[_i]; - if (statement.kind === 193 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { + if (statement.kind === 195 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; } @@ -22556,7 +23138,7 @@ var ts; if (produceDiagnostics) { // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 143 /* GetAccessor */) { + if (node.kind === 145 /* GetAccessor */) { 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); } @@ -22564,7 +23146,7 @@ var ts; if (!ts.hasDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 143 /* GetAccessor */ ? 144 /* SetAccessor */ : 143 /* GetAccessor */; + var otherKind = node.kind === 145 /* GetAccessor */ ? 146 /* SetAccessor */ : 145 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { @@ -22660,9 +23242,9 @@ var ts; var signaturesToCheck; // Unnamed (call\construct) signatures in interfaces are inherited and not shadowed so examining just node symbol won't give complete answer. // Use declaring type to obtain full list of signatures. - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 145 /* CallSignature */ || signatureDeclarationNode.kind === 146 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 145 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 215 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 147 /* CallSignature */ || signatureDeclarationNode.kind === 148 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 147 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -22680,7 +23262,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 213 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 215 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -22766,7 +23348,7 @@ var ts; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members - ts.Debug.assert(node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */); + ts.Debug.assert(node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */); ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -22802,7 +23384,7 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 213 /* InterfaceDeclaration */ || node.parent.kind === 153 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 215 /* InterfaceDeclaration */ || node.parent.kind === 155 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -22813,7 +23395,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 211 /* FunctionDeclaration */ || node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */ || node.kind === 142 /* Constructor */) { + if (node.kind === 213 /* FunctionDeclaration */ || node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */ || node.kind === 144 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -22953,16 +23535,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return d.name.kind === 9 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -22973,7 +23555,8 @@ var ts; } } function checkNonThenableType(type, location, message) { - if (!(type.flags & 1 /* Any */) && isTypeAssignableTo(type, getGlobalThenableType())) { + type = getWidenedType(type); + if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -23206,22 +23789,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 136 /* Parameter */: + case 138 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -23234,9 +23817,9 @@ var ts; // When we are emitting type metadata for decorators, we need to try to check the type // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. - if (node && node.kind === 149 /* TypeReference */) { + if (node && node.kind === 151 /* TypeReference */) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = root.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Resolve type so we know which symbol is referenced var rootSymbol = resolveName(root, root.text, meaning | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); // Resolved symbol is alias @@ -23255,19 +23838,19 @@ var ts; */ function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 136 /* Parameter */: + case 138 /* Parameter */: checkTypeNodeAsExpression(node.type); break; - case 141 /* MethodDeclaration */: + case 143 /* MethodDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 143 /* GetAccessor */: + case 145 /* GetAccessor */: checkTypeNodeAsExpression(node.type); break; - case 144 /* SetAccessor */: + case 146 /* SetAccessor */: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -23296,25 +23879,25 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 141 /* MethodDeclaration */: + case 143 /* MethodDeclaration */: checkParameterTypeAnnotationsAsExpressions(node); // fall-through - case 144 /* SetAccessor */: - case 143 /* GetAccessor */: - case 139 /* PropertyDeclaration */: - case 136 /* Parameter */: + case 146 /* SetAccessor */: + case 145 /* GetAccessor */: + case 141 /* PropertyDeclaration */: + case 138 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 136 /* Parameter */) { + if (node.kind === 138 /* Parameter */) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -23332,15 +23915,12 @@ var ts; checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { - if (!compilerOptions.experimentalAsyncFunctions) { - error(node, ts.Diagnostics.Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning); - } emitAwaiter = true; } // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 134 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 136 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -23389,11 +23969,11 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 190 /* Block */) { + if (node.kind === 192 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 217 /* ModuleBlock */) { + if (ts.isFunctionBlock(node) || node.kind === 219 /* ModuleBlock */) { checkFunctionAndClassExpressionBodies(node); } } @@ -23412,12 +23992,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 139 /* PropertyDeclaration */ || - node.kind === 138 /* PropertySignature */ || - node.kind === 141 /* MethodDeclaration */ || - node.kind === 140 /* MethodSignature */ || - node.kind === 143 /* GetAccessor */ || - node.kind === 144 /* SetAccessor */) { + if (node.kind === 141 /* PropertyDeclaration */ || + node.kind === 140 /* PropertySignature */ || + node.kind === 143 /* MethodDeclaration */ || + node.kind === 142 /* MethodSignature */ || + node.kind === 145 /* GetAccessor */ || + node.kind === 146 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -23426,7 +24006,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 136 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 138 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -23442,7 +24022,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 67 /* Identifier */; + var isDeclaration_1 = node.kind !== 69 /* Identifier */; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -23465,7 +24045,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 67 /* Identifier */; + var isDeclaration_2 = node.kind !== 69 /* Identifier */; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -23479,12 +24059,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 216 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 218 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 246 /* SourceFile */ && ts.isExternalModule(parent)) { + if (parent.kind === 248 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -23519,7 +24099,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 209 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 211 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -23529,17 +24109,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 191 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 193 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 190 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 217 /* ModuleBlock */ || - container.kind === 216 /* ModuleDeclaration */ || - container.kind === 246 /* SourceFile */); + (container.kind === 192 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 219 /* ModuleBlock */ || + container.kind === 218 /* ModuleDeclaration */ || + container.kind === 248 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -23554,18 +24134,18 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 136 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 138 /* Parameter */) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 67 /* Identifier */) { + if (n.kind === 69 /* Identifier */) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name and if this entry matches the resolved symbol if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 136 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 138 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -23591,7 +24171,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 134 /* ComputedPropertyName */) { + if (node.name.kind === 136 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -23602,7 +24182,7 @@ var ts; ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 136 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 138 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -23634,10 +24214,10 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); } } - if (node.kind !== 139 /* PropertyDeclaration */ && node.kind !== 138 /* PropertySignature */) { + if (node.kind !== 141 /* PropertyDeclaration */ && node.kind !== 140 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) { + if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -23660,7 +24240,7 @@ var ts; } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && node.parent.kind === 163 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 165 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -23698,12 +24278,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 212 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer.kind === 212 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -23723,14 +24303,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer.kind === 212 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); // There may be a destructuring assignment on the left side - if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* ObjectLiteralExpression */) { + if (varExpr.kind === 164 /* ArrayLiteralExpression */ || varExpr.kind === 165 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -23759,7 +24339,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer.kind === 212 /* VariableDeclarationList */) { 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); @@ -23773,7 +24353,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* ObjectLiteralExpression */) { + if (varExpr.kind === 164 /* ArrayLiteralExpression */ || varExpr.kind === 165 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { @@ -24012,7 +24592,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144 /* SetAccessor */))); + return !!(node.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -24035,10 +24615,10 @@ var ts; // for generators. return; } - if (func.kind === 144 /* SetAccessor */) { + if (func.kind === 146 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 142 /* Constructor */) { + else if (func.kind === 144 /* Constructor */) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -24047,7 +24627,12 @@ var ts; if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - checkTypeAssignableTo(awaitedType, promisedType, node.expression); + if (promisedType) { + // If the function has a return type, but promisedType is + // undefined, an error will be reported in checkAsyncFunctionReturnType + // so we don't need to report one here. + checkTypeAssignableTo(awaitedType, promisedType, node.expression); + } } else { checkTypeAssignableTo(exprType, returnType, node.expression); @@ -24074,7 +24659,7 @@ var ts; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 240 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 242 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -24086,7 +24671,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 239 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 241 /* CaseClause */) { var caseClause = clause; // TypeScript 1.0 spec (April 2014):5.9 // In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression. @@ -24107,7 +24692,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 205 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 207 /* LabeledStatement */ && 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; @@ -24137,7 +24722,7 @@ var ts; if (catchClause) { // Grammar checking if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 67 /* Identifier */) { + if (catchClause.variableDeclaration.name.kind !== 69 /* Identifier */) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -24212,7 +24797,7 @@ var ts; // perform property check if property or indexer is declared in 'type' // this allows to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (prop.valueDeclaration.name.kind === 134 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 136 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -24289,6 +24874,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { @@ -24307,7 +24893,7 @@ var ts; } } } - checkTypeAssignableTo(type, baseType, node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify @@ -24324,7 +24910,8 @@ var ts; } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { - ts.forEach(implementedTypeNodes, function (typeRefNode) { + for (var _b = 0; _b < implementedTypeNodes.length; _b++) { + var typeRefNode = implementedTypeNodes[_b]; if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } @@ -24334,14 +24921,14 @@ var ts; if (t !== unknownType) { var declaredType = (t.flags & 4096 /* Reference */) ? t.target : t; if (declaredType.flags & (1024 /* Class */ | 2048 /* Interface */)) { - checkTypeAssignableTo(type, t, node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { error(typeRefNode, ts.Diagnostics.A_class_may_only_implement_another_class_or_interface); } } } - }); + } } if (produceDiagnostics) { checkIndexConstraints(type); @@ -24392,7 +24979,7 @@ var ts; // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 256 /* Abstract */))) { - if (derivedClassDecl.kind === 184 /* ClassExpression */) { + if (derivedClassDecl.kind === 186 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -24440,7 +25027,7 @@ var ts; } } function isAccessor(kind) { - return kind === 143 /* GetAccessor */ || kind === 144 /* SetAccessor */; + return kind === 145 /* GetAccessor */ || kind === 146 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -24480,7 +25067,7 @@ var ts; var ok = true; for (var _i = 0; _i < baseTypes.length; _i++) { var base = baseTypes[_i]; - var properties = getPropertiesOfObjectType(base); + var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); for (var _a = 0; _a < properties.length; _a++) { var prop = properties[_a]; if (!ts.hasProperty(seen, prop.name)) { @@ -24510,7 +25097,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 215 /* InterfaceDeclaration */); 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); @@ -24519,19 +25106,21 @@ var ts; // Only check this symbol once if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); // run subsequent checks only if first set succeeded if (checkInheritedPropertiesAreIdentical(type, node.name)) { - ts.forEach(getBaseTypes(type), function (baseType) { - checkTypeAssignableTo(type, baseType, node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); - }); + for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) { + var baseType = _a[_i]; + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); + } checkIndexConstraints(type); } } // Interfaces cannot merge with non-ambient classes. if (symbol && symbol.declarations) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 212 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var declaration = _c[_b]; + if (declaration.kind === 214 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } @@ -24560,24 +25149,38 @@ var ts; if (!(nodeLinks.flags & 8192 /* EnumValuesComputed */)) { var enumSymbol = getSymbolOfNode(node); var enumType = getDeclaredTypeOfSymbol(enumSymbol); - var autoValue = 0; + var autoValue = 0; // set to undefined when enum member is non-constant var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); - ts.forEach(node.members, function (member) { - if (member.name.kind !== 134 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.name.kind === 136 /* ComputedPropertyName */) { + error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); + } + else if (isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } + var previousEnumMemberIsNonConstant = autoValue === undefined; var initializer = member.initializer; if (initializer) { autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); } else if (ambient && !enumIsConst) { + // In ambient enum declarations that specify no const modifier, enum member declarations + // that omit a value are considered computed members (as opposed to having auto-incremented values assigned). autoValue = undefined; } + else if (previousEnumMemberIsNonConstant) { + // If the member declaration specifies no value, the member is considered a constant enum member. + // If the member is the first member in the enum declaration, it is assigned the value zero. + // Otherwise, it is assigned the value of the immediately preceding member plus one, + // and an error occurs if the immediately preceding member is not a constant enum member + error(member.name, ts.Diagnostics.Enum_member_must_have_initializer); + } if (autoValue !== undefined) { getNodeLinks(member).enumMemberValue = autoValue++; } - }); + } nodeLinks.flags |= 8192 /* EnumValuesComputed */; } function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { @@ -24590,11 +25193,11 @@ var ts; if (enumIsConst) { error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); } - else if (!ambient) { + else if (ambient) { + error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); + } + else { // Only here do we need to check that the initializer is assignable to the enum type. - // If it is a constant value (not undefined), it is syntactically constrained to be a number. - // Also, we do not need to check this for ambients because there is already - // a syntax error if it is not a constant. checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); } } @@ -24610,7 +25213,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -24618,10 +25221,10 @@ var ts; switch (e.operator) { case 35 /* PlusToken */: return value_1; case 36 /* MinusToken */: return -value_1; - case 49 /* TildeToken */: return ~value_1; + case 50 /* TildeToken */: return ~value_1; } return undefined; - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -24631,31 +25234,31 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 46 /* BarToken */: return left | right; - case 45 /* AmpersandToken */: return left & right; - case 43 /* GreaterThanGreaterThanToken */: return left >> right; - case 44 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 42 /* LessThanLessThanToken */: return left << right; - case 47 /* CaretToken */: return left ^ right; + case 47 /* BarToken */: return left | right; + case 46 /* AmpersandToken */: return left & right; + case 44 /* GreaterThanGreaterThanToken */: return left >> right; + case 45 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 43 /* LessThanLessThanToken */: return left << right; + case 48 /* CaretToken */: return left ^ right; case 37 /* AsteriskToken */: return left * right; - case 38 /* SlashToken */: return left / right; + case 39 /* SlashToken */: return left / right; case 35 /* PlusToken */: return left + right; case 36 /* MinusToken */: return left - right; - case 39 /* PercentToken */: return left % right; + case 40 /* PercentToken */: return left % right; } return undefined; case 8 /* NumericLiteral */: return +e.text; - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return evalConstant(e.expression); - case 67 /* Identifier */: - case 165 /* ElementAccessExpression */: - case 164 /* PropertyAccessExpression */: + case 69 /* Identifier */: + case 167 /* ElementAccessExpression */: + case 166 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName; - if (e.kind === 67 /* Identifier */) { + if (e.kind === 69 /* Identifier */) { // unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work. // instead pick current enum type and later try to fetch member from the type enumType_1 = currentType; @@ -24663,7 +25266,7 @@ var ts; } else { var expression; - if (e.kind === 165 /* ElementAccessExpression */) { + if (e.kind === 167 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -24678,10 +25281,10 @@ var ts; // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName var current = expression; while (current) { - if (current.kind === 67 /* Identifier */) { + if (current.kind === 69 /* Identifier */) { break; } - else if (current.kind === 164 /* PropertyAccessExpression */) { + else if (current.kind === 166 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -24707,7 +25310,7 @@ var ts; return undefined; } // illegal case: forward reference - if (!isDefinedBefore(propertyDecl, member)) { + if (!isBlockScopedNameDeclaredBeforeUse(propertyDecl, member)) { reportError = false; error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; @@ -24722,7 +25325,7 @@ var ts; return; } // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -24752,7 +25355,7 @@ var ts; var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 215 /* EnumDeclaration */) { + if (declaration.kind !== 217 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -24775,8 +25378,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 212 /* ClassDeclaration */ || - (declaration.kind === 211 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 214 /* ClassDeclaration */ || + (declaration.kind === 213 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -24832,7 +25435,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 212 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 214 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -24841,9 +25444,9 @@ var ts; // Checks for ambient external modules. if (isAmbientExternalModule) { if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); } - if (isExternalModuleNameRelative(node.name.text)) { + if (ts.isExternalModuleNameRelative(node.name.text)) { error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); } } @@ -24852,17 +25455,17 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 133 /* QualifiedName */) { + if (node.kind === 135 /* QualifiedName */) { node = node.left; } - else if (node.kind === 164 /* PropertyAccessExpression */) { + else if (node.kind === 166 /* PropertyAccessExpression */) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 67 /* Identifier */); + ts.Debug.assert(node.kind === 69 /* Identifier */); return node; } function checkExternalImportOrExportDeclaration(node) { @@ -24871,14 +25474,14 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; - if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 226 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 219 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 248 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 228 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; } - if (inAmbientExternalModule && isExternalModuleNameRelative(moduleName.text)) { + if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { // TypeScript 1.0 spec (April 2013): 12.1.6 // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference // other external modules only through top - level external module names. @@ -24896,7 +25499,7 @@ var ts; (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 228 /* ExportSpecifier */ ? + var message = node.kind === 230 /* ExportSpecifier */ ? 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)); @@ -24923,7 +25526,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -24960,9 +25563,9 @@ var ts; } } else { - if (languageVersion >= 2 /* ES6 */ && !ts.isInAmbientContext(node)) { + if (modulekind === 5 /* ES6 */ && !ts.isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above - 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); + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } } @@ -24980,8 +25583,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; - if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 219 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 248 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -24995,7 +25598,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 246 /* SourceFile */ && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 216 /* ModuleDeclaration */) { + if (node.parent.kind !== 248 /* SourceFile */ && node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 218 /* ModuleDeclaration */) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -25010,8 +25613,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 246 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 216 /* ModuleDeclaration */ && container.name.kind === 67 /* Identifier */) { + var container = node.parent.kind === 248 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 218 /* ModuleDeclaration */ && container.name.kind === 69 /* Identifier */) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -25019,7 +25622,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 67 /* Identifier */) { + if (node.expression.kind === 69 /* Identifier */) { markExportAsReferenced(node); } else { @@ -25027,21 +25630,21 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (languageVersion >= 2 /* ES6 */) { - // export assignment is deprecated in es6 or above - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + if (modulekind === 5 /* ES6 */) { + // export assignment is not supported in es6 modules + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); } - else if (compilerOptions.module === 4 /* System */) { + else if (modulekind === 4 /* System */) { // system modules does not support export assignment grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); } } } function getModuleStatements(node) { - if (node.kind === 246 /* SourceFile */) { + if (node.kind === 248 /* SourceFile */) { return node.statements; } - if (node.kind === 216 /* ModuleDeclaration */ && node.body.kind === 217 /* ModuleBlock */) { + if (node.kind === 218 /* ModuleDeclaration */ && node.body.kind === 219 /* ModuleBlock */) { return node.body.statements; } return emptyArray; @@ -25080,118 +25683,118 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessivly // hitting the cancellation token on every node we check. switch (kind) { - case 216 /* ModuleDeclaration */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 211 /* FunctionDeclaration */: + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 135 /* TypeParameter */: + case 137 /* TypeParameter */: return checkTypeParameter(node); - case 136 /* Parameter */: + case 138 /* Parameter */: return checkParameter(node); - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return checkPropertyDeclaration(node); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 147 /* IndexSignature */: + case 149 /* IndexSignature */: return checkSignatureDeclaration(node); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return checkMethodDeclaration(node); - case 142 /* Constructor */: + case 144 /* Constructor */: return checkConstructorDeclaration(node); - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return checkAccessorDeclaration(node); - case 149 /* TypeReference */: + case 151 /* TypeReference */: return checkTypeReferenceNode(node); - case 148 /* TypePredicate */: + case 150 /* TypePredicate */: return checkTypePredicate(node); - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return checkTypeQuery(node); - case 153 /* TypeLiteral */: + case 155 /* TypeLiteral */: return checkTypeLiteral(node); - case 154 /* ArrayType */: + case 156 /* ArrayType */: return checkArrayType(node); - case 155 /* TupleType */: + case 157 /* TupleType */: return checkTupleType(node); - case 156 /* UnionType */: - case 157 /* IntersectionType */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 158 /* ParenthesizedType */: + case 160 /* ParenthesizedType */: return checkSourceElement(node.type); - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 190 /* Block */: - case 217 /* ModuleBlock */: + case 192 /* Block */: + case 219 /* ModuleBlock */: return checkBlock(node); - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: return checkVariableStatement(node); - case 193 /* ExpressionStatement */: + case 195 /* ExpressionStatement */: return checkExpressionStatement(node); - case 194 /* IfStatement */: + case 196 /* IfStatement */: return checkIfStatement(node); - case 195 /* DoStatement */: + case 197 /* DoStatement */: return checkDoStatement(node); - case 196 /* WhileStatement */: + case 198 /* WhileStatement */: return checkWhileStatement(node); - case 197 /* ForStatement */: + case 199 /* ForStatement */: return checkForStatement(node); - case 198 /* ForInStatement */: + case 200 /* ForInStatement */: return checkForInStatement(node); - case 199 /* ForOfStatement */: + case 201 /* ForOfStatement */: return checkForOfStatement(node); - case 200 /* ContinueStatement */: - case 201 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 202 /* ReturnStatement */: + case 204 /* ReturnStatement */: return checkReturnStatement(node); - case 203 /* WithStatement */: + case 205 /* WithStatement */: return checkWithStatement(node); - case 204 /* SwitchStatement */: + case 206 /* SwitchStatement */: return checkSwitchStatement(node); - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: return checkLabeledStatement(node); - case 206 /* ThrowStatement */: + case 208 /* ThrowStatement */: return checkThrowStatement(node); - case 207 /* TryStatement */: + case 209 /* TryStatement */: return checkTryStatement(node); - case 209 /* VariableDeclaration */: + case 211 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 161 /* BindingElement */: + case 163 /* BindingElement */: return checkBindingElement(node); - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: return checkClassDeclaration(node); - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: return checkImportDeclaration(node); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return checkExportDeclaration(node); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return checkExportAssignment(node); - case 192 /* EmptyStatement */: + case 194 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 208 /* DebuggerStatement */: + case 210 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 229 /* MissingDeclaration */: + case 231 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -25206,97 +25809,98 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 184 /* ClassExpression */: + case 186 /* ClassExpression */: ts.forEach(node.members, checkSourceElement); + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 203 /* WithStatement */: + case 205 /* WithStatement */: checkFunctionAndClassExpressionBodies(node.expression); break; - case 137 /* Decorator */: - case 136 /* Parameter */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 159 /* ObjectBindingPattern */: - case 160 /* ArrayBindingPattern */: - case 161 /* BindingElement */: - case 162 /* ArrayLiteralExpression */: - case 163 /* ObjectLiteralExpression */: - case 243 /* PropertyAssignment */: - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 168 /* TaggedTemplateExpression */: - case 181 /* TemplateExpression */: - case 188 /* TemplateSpan */: - case 169 /* TypeAssertionExpression */: - case 187 /* AsExpression */: - case 170 /* ParenthesizedExpression */: - case 174 /* TypeOfExpression */: - case 175 /* VoidExpression */: - case 176 /* AwaitExpression */: - case 173 /* DeleteExpression */: - case 177 /* PrefixUnaryExpression */: - case 178 /* PostfixUnaryExpression */: - case 179 /* BinaryExpression */: - case 180 /* ConditionalExpression */: - case 183 /* SpreadElementExpression */: - case 182 /* YieldExpression */: - case 190 /* Block */: - case 217 /* ModuleBlock */: - case 191 /* VariableStatement */: - case 193 /* ExpressionStatement */: - case 194 /* IfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 200 /* ContinueStatement */: - case 201 /* BreakStatement */: - case 202 /* ReturnStatement */: - case 204 /* SwitchStatement */: - case 218 /* CaseBlock */: - case 239 /* CaseClause */: - case 240 /* DefaultClause */: - case 205 /* LabeledStatement */: - case 206 /* ThrowStatement */: - case 207 /* TryStatement */: - case 242 /* CatchClause */: - case 209 /* VariableDeclaration */: - case 210 /* VariableDeclarationList */: - case 212 /* ClassDeclaration */: - case 241 /* HeritageClause */: - case 186 /* ExpressionWithTypeArguments */: - case 215 /* EnumDeclaration */: - case 245 /* EnumMember */: - case 225 /* ExportAssignment */: - case 246 /* SourceFile */: - case 238 /* JsxExpression */: - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - case 236 /* JsxAttribute */: - case 237 /* JsxSpreadAttribute */: - case 233 /* JsxOpeningElement */: + case 139 /* Decorator */: + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + case 163 /* BindingElement */: + case 164 /* ArrayLiteralExpression */: + case 165 /* ObjectLiteralExpression */: + case 245 /* PropertyAssignment */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 170 /* TaggedTemplateExpression */: + case 183 /* TemplateExpression */: + case 190 /* TemplateSpan */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: + case 172 /* ParenthesizedExpression */: + case 176 /* TypeOfExpression */: + case 177 /* VoidExpression */: + case 178 /* AwaitExpression */: + case 175 /* DeleteExpression */: + case 179 /* PrefixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: + case 181 /* BinaryExpression */: + case 182 /* ConditionalExpression */: + case 185 /* SpreadElementExpression */: + case 184 /* YieldExpression */: + case 192 /* Block */: + case 219 /* ModuleBlock */: + case 193 /* VariableStatement */: + case 195 /* ExpressionStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: + case 204 /* ReturnStatement */: + case 206 /* SwitchStatement */: + case 220 /* CaseBlock */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + case 207 /* LabeledStatement */: + case 208 /* ThrowStatement */: + case 209 /* TryStatement */: + case 244 /* CatchClause */: + case 211 /* VariableDeclaration */: + case 212 /* VariableDeclarationList */: + case 214 /* ClassDeclaration */: + case 243 /* HeritageClause */: + case 188 /* ExpressionWithTypeArguments */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 227 /* ExportAssignment */: + case 248 /* SourceFile */: + case 240 /* JsxExpression */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 238 /* JsxAttribute */: + case 239 /* JsxSpreadAttribute */: + case 235 /* JsxOpeningElement */: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -25323,7 +25927,7 @@ var ts; potentialThisCollisions.length = 0; ts.forEach(node.statements, checkSourceElement); checkFunctionAndClassExpressionBodies(node); - if (ts.isExternalModule(node)) { + if (ts.isExternalOrCommonJsModule(node)) { checkExternalModuleExports(node); } if (potentialThisCollisions.length) { @@ -25382,7 +25986,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 203 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 205 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -25405,34 +26009,34 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 246 /* SourceFile */: - if (!ts.isExternalModule(location)) { + case 248 /* SourceFile */: + if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 184 /* ClassExpression */: + case 186 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } // fall through; this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, - // add the type parameters into the symbol table + // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!(memberFlags & 128 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 171 /* FunctionExpression */: + case 173 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -25475,43 +26079,43 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 67 /* Identifier */ && + return name.kind === 69 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 135 /* TypeParameter */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 215 /* EnumDeclaration */: + case 137 /* TypeParameter */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 217 /* EnumDeclaration */: return true; } } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 133 /* QualifiedName */) { + while (node.parent && node.parent.kind === 135 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 149 /* TypeReference */; + return node.parent && node.parent.kind === 151 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 164 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 166 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 186 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 188 /* ExpressionWithTypeArguments */; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 133 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 135 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 219 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 221 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 225 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 227 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -25523,11 +26127,11 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 225 /* ExportAssignment */) { + if (entityName.parent.kind === 227 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 164 /* PropertyAccessExpression */) { + if (entityName.kind !== 166 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -25537,13 +26141,24 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 186 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = 0 /* None */; + // In an interface or class, we're definitely interested in a type. + if (entityName.parent.kind === 188 /* ExpressionWithTypeArguments */) { + meaning = 793056 /* Type */; + // In a class 'extends' clause we are also looking for a value. + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + meaning |= 107455 /* Value */; + } + } + else { + meaning = 1536 /* Namespace */; + } meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 233 /* JsxOpeningElement */) || - (entityName.parent.kind === 232 /* JsxSelfClosingElement */) || - (entityName.parent.kind === 235 /* JsxClosingElement */)) { + else if ((entityName.parent.kind === 235 /* JsxOpeningElement */) || + (entityName.parent.kind === 234 /* JsxSelfClosingElement */) || + (entityName.parent.kind === 237 /* JsxClosingElement */)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { @@ -25551,20 +26166,20 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 67 /* Identifier */) { + if (entityName.kind === 69 /* Identifier */) { // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 164 /* PropertyAccessExpression */) { + else if (entityName.kind === 166 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 133 /* QualifiedName */) { + else if (entityName.kind === 135 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -25573,16 +26188,16 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 236 /* JsxAttribute */) { + else if (entityName.parent.kind === 238 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 148 /* TypePredicate */) { + if (entityName.parent.kind === 150 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? @@ -25597,14 +26212,14 @@ var ts; // This is a declaration, call getSymbolOfNode return getSymbolOfNode(node.parent); } - if (node.kind === 67 /* Identifier */) { + if (node.kind === 69 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 225 /* ExportAssignment */ + return node.parent.kind === 227 /* ExportAssignment */ ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } - else if (node.parent.kind === 161 /* BindingElement */ && - node.parent.parent.kind === 159 /* ObjectBindingPattern */ && + else if (node.parent.kind === 163 /* BindingElement */ && + node.parent.parent.kind === 161 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -25614,18 +26229,18 @@ var ts; } } switch (node.kind) { - case 67 /* Identifier */: - case 164 /* PropertyAccessExpression */: - case 133 /* QualifiedName */: + case 69 /* Identifier */: + case 166 /* PropertyAccessExpression */: + case 135 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 95 /* ThisKeyword */: - case 93 /* SuperKeyword */: - var type = checkExpression(node); + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: + var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 119 /* ConstructorKeyword */: + case 121 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 142 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 144 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -25633,14 +26248,14 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 220 /* ImportDeclaration */ || node.parent.kind === 226 /* ExportDeclaration */) && + ((node.parent.kind === 222 /* ImportDeclaration */ || node.parent.kind === 228 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } // Fall through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -25657,7 +26272,7 @@ var ts; // The function returns a value symbol of an identifier in the short-hand property assignment. // This is necessary as an identifier in short-hand property assignment can contains two meaning: // property name and property value. - if (location && location.kind === 244 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 246 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */); } return undefined; @@ -25774,11 +26389,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 246 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 248 /* SourceFile */) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 216 /* ModuleDeclaration */ || n.kind === 215 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 218 /* ModuleDeclaration */ || n.kind === 217 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -25793,11 +26408,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 190 /* Block */: - case 218 /* CaseBlock */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 192 /* Block */: + case 220 /* CaseBlock */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: return true; } return false; @@ -25827,22 +26442,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 219 /* ImportEqualsDeclaration */: - case 221 /* ImportClause */: - case 222 /* NamespaceImport */: - case 224 /* ImportSpecifier */: - case 228 /* ExportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 225 /* ExportAssignment */: - return node.expression && node.expression.kind === 67 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 227 /* ExportAssignment */: + return node.expression && node.expression.kind === 69 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 246 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 248 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -25904,7 +26519,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 245 /* EnumMember */) { + if (node.kind === 247 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -25996,23 +26611,6 @@ var ts; var symbol = getReferencedValueSymbol(reference); return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; } - function getBlockScopedVariableId(n) { - ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 161 /* BindingElement */ || (n.parent.kind === 209 /* VariableDeclaration */ && n.parent.name === n); - var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || - getNodeLinks(n).resolvedSymbol || - resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); - var isLetOrConst = symbol && - (symbol.flags & 2 /* BlockScopedVariable */) && - symbol.valueDeclaration.parent.kind !== 242 /* CatchClause */; - if (isLetOrConst) { - // side-effect of calling this method: - // assign id to symbol if it was not yet set - getSymbolLinks(symbol); - return symbol.id; - } - return undefined; - } function instantiateSingleCallFunctionType(functionType, typeArguments) { if (functionType === unknownType) { return unknownType; @@ -26044,7 +26642,6 @@ var ts; isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, collectLinkedAliases: collectLinkedAliases, - getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, isOptionalParameter: isOptionalParameter @@ -26057,11 +26654,10 @@ var ts; }); // Initialize global symbol table ts.forEach(host.getSourceFiles(), function (file) { - if (!ts.isExternalModule(file)) { + if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } }); - // Initialize special symbols getSymbolLinks(undefinedSymbol).type = undefinedType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); getSymbolLinks(unknownSymbol).type = unknownType; @@ -26087,6 +26683,7 @@ var ts; getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); getGlobalThenableType = ts.memoize(createThenableType); + cjsRequireType = getExportedTypeFromNamespace("CommonJS", "Require"); // If we're in ES6 mode, load the TemplateStringsArray. // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. if (languageVersion >= 2 /* ES6 */) { @@ -26136,10 +26733,7 @@ var ts; if (!ts.nodeCanBeDecorated(node)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } - else if (languageVersion < 1 /* ES5 */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* SetAccessor */) { + else if (node.kind === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -26149,38 +26743,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 142 /* Constructor */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 147 /* IndexSignature */: - case 216 /* ModuleDeclaration */: - case 220 /* ImportDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 226 /* ExportDeclaration */: - case 225 /* ExportAssignment */: - case 136 /* Parameter */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 149 /* IndexSignature */: + case 218 /* ModuleDeclaration */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 228 /* ExportDeclaration */: + case 227 /* ExportAssignment */: + case 138 /* Parameter */: break; - case 211 /* FunctionDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116 /* AsyncKeyword */) && - node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { + case 213 /* FunctionDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118 /* AsyncKeyword */) && + node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 191 /* VariableStatement */: - case 214 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 193 /* VariableStatement */: + case 216 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 215 /* EnumDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72 /* ConstKeyword */) && - node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { + case 217 /* EnumDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74 /* ConstKeyword */) && + node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -26195,14 +26789,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { - case 110 /* PublicKeyword */: - case 109 /* ProtectedKeyword */: - case 108 /* PrivateKeyword */: + case 112 /* PublicKeyword */: + case 111 /* ProtectedKeyword */: + case 110 /* PrivateKeyword */: var text = void 0; - if (modifier.kind === 110 /* PublicKeyword */) { + if (modifier.kind === 112 /* PublicKeyword */) { text = "public"; } - else if (modifier.kind === 109 /* ProtectedKeyword */) { + else if (modifier.kind === 111 /* ProtectedKeyword */) { text = "protected"; lastProtected = modifier; } @@ -26219,11 +26813,11 @@ var ts; else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { + else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256 /* Abstract */) { - if (modifier.kind === 108 /* PrivateKeyword */) { + if (modifier.kind === 110 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -26232,17 +26826,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 111 /* StaticKeyword */: + case 113 /* StaticKeyword */: if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { + else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 136 /* Parameter */) { + else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256 /* Abstract */) { @@ -26251,7 +26845,7 @@ var ts; flags |= 128 /* Static */; lastStatic = modifier; break; - case 80 /* ExportKeyword */: + case 82 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -26264,42 +26858,42 @@ var ts; else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 212 /* ClassDeclaration */) { + else if (node.parent.kind === 214 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 136 /* Parameter */) { + else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 120 /* DeclareKeyword */: + case 122 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 212 /* ClassDeclaration */) { + else if (node.parent.kind === 214 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 136 /* Parameter */) { + else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 113 /* AbstractKeyword */: + case 115 /* AbstractKeyword */: if (flags & 256 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 212 /* ClassDeclaration */) { - if (node.kind !== 141 /* MethodDeclaration */) { + if (node.kind !== 214 /* ClassDeclaration */) { + if (node.kind !== 143 /* MethodDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 212 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { + if (!(node.parent.kind === 214 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128 /* Static */) { @@ -26311,14 +26905,14 @@ var ts; } flags |= 256 /* Abstract */; break; - case 116 /* AsyncKeyword */: + case 118 /* AsyncKeyword */: if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 136 /* Parameter */) { + else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512 /* Async */; @@ -26326,7 +26920,7 @@ var ts; break; } } - if (node.kind === 142 /* Constructor */) { + if (node.kind === 144 /* Constructor */) { if (flags & 128 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -26344,10 +26938,10 @@ var ts; } return; } - else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 136 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 138 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512 /* Async */) { @@ -26359,10 +26953,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 141 /* MethodDeclaration */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -26428,7 +27022,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 172 /* ArrowFunction */) { + if (node.kind === 174 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -26463,7 +27057,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 !== 128 /* StringKeyword */ && parameter.type.kind !== 126 /* NumberKeyword */) { + if (parameter.type.kind !== 130 /* StringKeyword */ && parameter.type.kind !== 128 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -26496,7 +27090,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 185 /* OmittedExpression */) { + if (arg.kind === 187 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -26523,7 +27117,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 81 /* ExtendsKeyword */) { + if (heritageClause.token === 83 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -26536,7 +27130,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -26552,14 +27146,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 81 /* ExtendsKeyword */) { + if (heritageClause.token === 83 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -26570,19 +27164,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 134 /* ComputedPropertyName */) { + if (node.kind !== 136 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 179 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { + if (computedPropertyName.expression.kind === 181 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 211 /* FunctionDeclaration */ || - node.kind === 171 /* FunctionExpression */ || - node.kind === 141 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 213 /* FunctionDeclaration */ || + node.kind === 173 /* FunctionExpression */ || + node.kind === 143 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -26599,7 +27193,7 @@ var ts; return grammarErrorOnNode(questionToken, message); } } - function checkGrammarObjectLiteralExpression(node) { + function checkGrammarObjectLiteralExpression(node, inDestructuring) { var seen = {}; var Property = 1; var GetAccessor = 2; @@ -26608,12 +27202,17 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_16 = prop.name; - if (prop.kind === 185 /* OmittedExpression */ || - name_16.kind === 134 /* ComputedPropertyName */) { + if (prop.kind === 187 /* OmittedExpression */ || + name_16.kind === 136 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_16); continue; } + if (prop.kind === 246 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern + // outside of destructuring it is a syntax error + return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); + } // ECMA-262 11.1.5 Object Initialiser // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true // a.This production is contained in strict code and IsDataDescriptor(previous) is true and @@ -26623,7 +27222,7 @@ var ts; // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; - if (prop.kind === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */) { + if (prop.kind === 245 /* PropertyAssignment */ || prop.kind === 246 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_16.kind === 8 /* NumericLiteral */) { @@ -26631,13 +27230,13 @@ var ts; } currentKind = Property; } - else if (prop.kind === 141 /* MethodDeclaration */) { + else if (prop.kind === 143 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 143 /* GetAccessor */) { + else if (prop.kind === 145 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 144 /* SetAccessor */) { + else if (prop.kind === 146 /* SetAccessor */) { currentKind = SetAccesor; } else { @@ -26669,7 +27268,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 237 /* JsxSpreadAttribute */) { + if (attr.kind === 239 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; @@ -26681,7 +27280,7 @@ var ts; return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 238 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 240 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -26690,24 +27289,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 210 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 212 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ ? 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 === 198 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ ? 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 = forInOrOfStatement.kind === 198 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ ? 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); @@ -26730,10 +27329,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 143 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 145 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 144 /* SetAccessor */) { + else if (kind === 146 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -26758,7 +27357,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 134 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 136 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -26768,7 +27367,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 163 /* ObjectLiteralExpression */) { + if (node.parent.kind === 165 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -26792,22 +27391,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 === 213 /* InterfaceDeclaration */) { + else if (node.parent.kind === 215 /* InterfaceDeclaration */) { 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 === 153 /* TypeLiteral */) { + else if (node.parent.kind === 155 /* TypeLiteral */) { 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 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: return true; - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -26819,11 +27418,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 200 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 202 /* ContinueStatement */ && !isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -26831,8 +27430,8 @@ var ts; return false; } break; - case 204 /* SwitchStatement */: - if (node.kind === 201 /* BreakStatement */ && !node.label) { + case 206 /* SwitchStatement */: + if (node.kind === 203 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -26847,13 +27446,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 201 /* BreakStatement */ + var message = node.kind === 203 /* BreakStatement */ ? 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 === 201 /* BreakStatement */ + var message = node.kind === 203 /* BreakStatement */ ? 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); @@ -26865,7 +27464,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 160 /* ArrayBindingPattern */ || node.name.kind === 159 /* ObjectBindingPattern */) { + if (node.name.kind === 162 /* ArrayBindingPattern */ || node.name.kind === 161 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -26875,7 +27474,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 198 /* ForInStatement */ && node.parent.parent.kind !== 199 /* ForOfStatement */) { + if (node.parent.parent.kind !== 200 /* ForInStatement */ && node.parent.parent.kind !== 201 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -26902,7 +27501,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 67 /* Identifier */) { + if (name.kind === 69 /* Identifier */) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -26911,7 +27510,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 185 /* OmittedExpression */) { + if (element.kind !== 187 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -26928,15 +27527,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 194 /* IfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 203 /* WithStatement */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: return false; - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -26952,7 +27551,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 177 /* PrefixUnaryExpression */) { + if (expression.kind === 179 /* PrefixUnaryExpression */) { var unaryExpression = expression; if (unaryExpression.operator === 35 /* PlusToken */ || unaryExpression.operator === 36 /* MinusToken */) { expression = unaryExpression.operand; @@ -26968,37 +27567,6 @@ var ts; } return false; } - function checkGrammarEnumDeclaration(enumDecl) { - var enumIsConst = (enumDecl.flags & 32768 /* Const */) !== 0; - var hasError = false; - // skip checks below for const enums - they allow arbitrary initializers as long as they can be evaluated to constant expressions. - // since all values are known in compile time - it is not necessary to check that constant enum section precedes computed enum members. - if (!enumIsConst) { - var inConstantEnumMemberSection = true; - var inAmbientContext = ts.isInAmbientContext(enumDecl); - for (var _i = 0, _a = enumDecl.members; _i < _a.length; _i++) { - var node = _a[_i]; - // Do not use hasDynamicName here, because that returns false for well known symbols. - // We want to perform checkComputedPropertyName for all computed properties, including - // well known symbols. - if (node.name.kind === 134 /* ComputedPropertyName */) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); - } - else if (inAmbientContext) { - if (node.initializer && !isIntegerLiteral(node.initializer)) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers) || hasError; - } - } - else if (node.initializer) { - inConstantEnumMemberSection = isIntegerLiteral(node.initializer); - } - else if (!inConstantEnumMemberSection) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Enum_member_must_have_initializer) || hasError; - } - } - } - return hasError; - } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -27024,7 +27592,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 67 /* Identifier */ && + return node.kind === 69 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -27044,12 +27612,12 @@ var ts; return true; } } - else if (node.parent.kind === 213 /* InterfaceDeclaration */) { + else if (node.parent.kind === 215 /* InterfaceDeclaration */) { 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 === 153 /* TypeLiteral */) { + else if (node.parent.kind === 155 /* TypeLiteral */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -27069,11 +27637,11 @@ var ts; // export_opt ExternalImportDeclaration // export_opt AmbientDeclaration // - if (node.kind === 213 /* InterfaceDeclaration */ || - node.kind === 220 /* ImportDeclaration */ || - node.kind === 219 /* ImportEqualsDeclaration */ || - node.kind === 226 /* ExportDeclaration */ || - node.kind === 225 /* ExportAssignment */ || + if (node.kind === 215 /* InterfaceDeclaration */ || + node.kind === 222 /* ImportDeclaration */ || + node.kind === 221 /* ImportEqualsDeclaration */ || + node.kind === 228 /* ExportDeclaration */ || + node.kind === 227 /* ExportAssignment */ || (node.flags & 2 /* Ambient */) || (node.flags & (1 /* Export */ | 1024 /* Default */))) { return false; @@ -27083,7 +27651,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 191 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 193 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -27109,7 +27677,7 @@ var ts; // to prevent noisyness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 190 /* Block */ || node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { + if (node.parent.kind === 192 /* Block */ || node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -27160,6 +27728,7 @@ var ts; var enclosingDeclaration; var currentSourceFile; var reportedDeclarationError = false; + var errorNameNode; var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var moduleElementDeclarationEmitInfo = []; @@ -27191,7 +27760,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 220 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 222 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -27245,6 +27814,7 @@ var ts; function createAndSetNewTextWriterWithSymbolWriter() { var writer = ts.createTextWriter(newLine); writer.trackSymbol = trackSymbol; + writer.reportInaccessibleThisError = reportInaccessibleThisError; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -27267,10 +27837,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 209 /* VariableDeclaration */) { + if (declaration.kind === 211 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 223 /* NamedImports */ || declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 221 /* ImportClause */) { + else if (declaration.kind === 225 /* NamedImports */ || declaration.kind === 226 /* ImportSpecifier */ || declaration.kind === 223 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -27288,7 +27858,7 @@ var ts; // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, // we would write alias foo declaration when we visit it since it would now be marked as visible if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 220 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 222 /* ImportDeclaration */) { // we have to create asynchronous output only after we have collected complete information // because it is possible to enable multiple bindings as asynchronously visible moduleElementEmitInfo.isVisible = true; @@ -27298,12 +27868,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 216 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 218 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 216 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 218 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -27337,6 +27907,11 @@ var ts; function trackSymbol(symbol, enclosingDeclaration, meaning) { handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); } + function reportInaccessibleThisError() { + if (errorNameNode) { + diagnostics.push(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode))); + } + } function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); @@ -27345,7 +27920,9 @@ var ts; emitType(type); } else { + errorNameNode = declaration.name; resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + errorNameNode = undefined; } } function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { @@ -27356,7 +27933,9 @@ var ts; emitType(signature.type); } else { + errorNameNode = signature.name; resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + errorNameNode = undefined; } } function emitLines(nodes) { @@ -27395,49 +27974,50 @@ var ts; } function emitType(type) { switch (type.kind) { - case 115 /* AnyKeyword */: - case 128 /* StringKeyword */: - case 126 /* NumberKeyword */: - case 118 /* BooleanKeyword */: - case 129 /* SymbolKeyword */: - case 101 /* VoidKeyword */: + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: + case 97 /* ThisKeyword */: case 9 /* StringLiteral */: return writeTextOfNode(currentSourceFile, type); - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 149 /* TypeReference */: + case 151 /* TypeReference */: return emitTypeReference(type); - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return emitTypeQuery(type); - case 154 /* ArrayType */: + case 156 /* ArrayType */: return emitArrayType(type); - case 155 /* TupleType */: + case 157 /* TupleType */: return emitTupleType(type); - case 156 /* UnionType */: + case 158 /* UnionType */: return emitUnionType(type); - case 157 /* IntersectionType */: + case 159 /* IntersectionType */: return emitIntersectionType(type); - case 158 /* ParenthesizedType */: + case 160 /* ParenthesizedType */: return emitParenType(type); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 153 /* TypeLiteral */: + case 155 /* TypeLiteral */: return emitTypeLiteral(type); - case 67 /* Identifier */: + case 69 /* Identifier */: return emitEntityName(type); - case 133 /* QualifiedName */: + case 135 /* QualifiedName */: return emitEntityName(type); - case 148 /* TypePredicate */: + case 150 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 67 /* Identifier */) { + if (entityName.kind === 69 /* Identifier */) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 133 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 133 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 135 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 135 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); @@ -27446,13 +28026,13 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 219 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 221 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 67 /* Identifier */ || node.expression.kind === 164 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 69 /* Identifier */ || node.expression.kind === 166 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -27533,7 +28113,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 67 /* Identifier */) { + if (node.expression.kind === 69 /* Identifier */) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -27553,7 +28133,7 @@ var ts; write(";"); writeLine(); // Make all the declarations visible for the export name - if (node.expression.kind === 67 /* Identifier */) { + if (node.expression.kind === 69 /* Identifier */) { var nodes = resolver.collectLinkedAliases(node.expression); // write each of these declarations asynchronously writeAsynchronousModuleElements(nodes); @@ -27572,10 +28152,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 219 /* ImportEqualsDeclaration */ || - (node.parent.kind === 246 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 221 /* ImportEqualsDeclaration */ || + (node.parent.kind === 248 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 248 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -27585,7 +28165,7 @@ var ts; }); } else { - if (node.kind === 220 /* ImportDeclaration */) { + if (node.kind === 222 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -27603,23 +28183,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: return writeVariableStatement(node); - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: return writeClassDeclaration(node); - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -27635,7 +28215,7 @@ var ts; if (node.flags & 1024 /* Default */) { write("default "); } - else if (node.kind !== 213 /* InterfaceDeclaration */) { + else if (node.kind !== 215 /* InterfaceDeclaration */) { write("declare "); } } @@ -27684,7 +28264,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 222 /* NamespaceImport */) { + if (namedBindings.kind === 224 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -27712,7 +28292,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 224 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -27770,7 +28350,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 217 /* ModuleBlock */) { + while (node.body.kind !== 219 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -27835,7 +28415,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 141 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 143 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -27846,15 +28426,15 @@ var ts; // If there is constraint present and this is not a type parameter of the private method emit the constraint if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 150 /* FunctionType */ || - node.parent.kind === 151 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 153 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 141 /* MethodDeclaration */ || - node.parent.kind === 140 /* MethodSignature */ || - node.parent.kind === 150 /* FunctionType */ || - node.parent.kind === 151 /* ConstructorType */ || - node.parent.kind === 145 /* CallSignature */ || - node.parent.kind === 146 /* ConstructSignature */); + if (node.parent.kind === 152 /* FunctionType */ || + node.parent.kind === 153 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 155 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 143 /* MethodDeclaration */ || + node.parent.kind === 142 /* MethodSignature */ || + node.parent.kind === 152 /* FunctionType */ || + node.parent.kind === 153 /* ConstructorType */ || + node.parent.kind === 147 /* CallSignature */ || + node.parent.kind === 148 /* ConstructSignature */); emitType(node.constraint); } else { @@ -27865,31 +28445,31 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 146 /* ConstructSignature */: + case 148 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 145 /* CallSignature */: + case 147 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { 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 === 212 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 214 /* ClassDeclaration */) { 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 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -27917,13 +28497,13 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 91 /* NullKeyword */) { + else if (!isImplementsList && node.expression.kind === 93 /* NullKeyword */) { write("null"); } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 212 /* ClassDeclaration */) { + if (node.parent.parent.kind === 214 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -28007,7 +28587,7 @@ var ts; function emitVariableDeclaration(node) { // If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted // so there is no check needed to see if declaration is visible - if (node.kind !== 209 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 211 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -28017,10 +28597,10 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentSourceFile, node.name); // If optional property emit ? - if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && node.parent.kind === 153 /* TypeLiteral */) { + if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && node.parent.kind === 155 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { @@ -28029,14 +28609,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 209 /* VariableDeclaration */) { + if (node.kind === 211 /* VariableDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? 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 === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) { + else if (node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (node.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? @@ -28045,7 +28625,7 @@ var ts; 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 === 212 /* ClassDeclaration */) { + else if (node.parent.kind === 214 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -28077,7 +28657,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 185 /* OmittedExpression */) { + if (element.kind !== 187 /* OmittedExpression */) { elements.push(element); } } @@ -28147,7 +28727,7 @@ var ts; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 143 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 145 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -28160,7 +28740,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 143 /* GetAccessor */ + return accessor.kind === 145 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -28169,7 +28749,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 144 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 146 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? @@ -28219,17 +28799,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 211 /* FunctionDeclaration */) { + if (node.kind === 213 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 141 /* MethodDeclaration */) { + else if (node.kind === 143 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 211 /* FunctionDeclaration */) { + if (node.kind === 213 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 142 /* Constructor */) { + else if (node.kind === 144 /* Constructor */) { write("constructor"); } else { @@ -28247,11 +28827,11 @@ var ts; } function emitSignatureDeclaration(node) { // Construct signature or constructor type write new Signature - if (node.kind === 146 /* ConstructSignature */ || node.kind === 151 /* ConstructorType */) { + if (node.kind === 148 /* ConstructSignature */ || node.kind === 153 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 147 /* IndexSignature */) { + if (node.kind === 149 /* IndexSignature */) { write("["); } else { @@ -28261,22 +28841,22 @@ var ts; enclosingDeclaration = node; // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 147 /* IndexSignature */) { + if (node.kind === 149 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 150 /* FunctionType */ || node.kind === 151 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 153 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 152 /* FunctionType */ || node.kind === 153 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 155 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 142 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 144 /* Constructor */ && !(node.flags & 32 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -28287,26 +28867,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 146 /* ConstructSignature */: + case 148 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named 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 145 /* CallSignature */: + case 147 /* CallSignature */: // Interfaces cannot have return types that cannot be named 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 147 /* IndexSignature */: + case 149 /* IndexSignature */: // Interfaces cannot have return types that cannot be named 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 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -28314,7 +28894,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 === 212 /* ClassDeclaration */) { + else if (node.parent.kind === 214 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -28328,7 +28908,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -28363,9 +28943,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 150 /* FunctionType */ || - node.parent.kind === 151 /* ConstructorType */ || - node.parent.parent.kind === 153 /* TypeLiteral */) { + if (node.parent.kind === 152 /* FunctionType */ || + node.parent.kind === 153 /* ConstructorType */ || + node.parent.parent.kind === 155 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { @@ -28381,24 +28961,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 142 /* Constructor */: + case 144 /* Constructor */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? 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; - case 146 /* ConstructSignature */: + case 148 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return 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; - case 145 /* CallSignature */: + case 147 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return 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; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -28406,7 +28986,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 === 212 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 214 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -28419,7 +28999,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -28431,12 +29011,12 @@ var ts; } function emitBindingPattern(bindingPattern) { // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. - if (bindingPattern.kind === 159 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 161 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 160 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 162 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -28455,7 +29035,7 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 185 /* OmittedExpression */) { + if (bindingElement.kind === 187 /* OmittedExpression */) { // If bindingElement is an omittedExpression (i.e. containing elision), // we will emit blank space (although this may differ from users' original code, // it allows emitSeparatedList to write separator appropriately) @@ -28464,7 +29044,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 161 /* BindingElement */) { + else if (bindingElement.kind === 163 /* BindingElement */) { if (bindingElement.propertyName) { // bindingElement has propertyName property in the following case: // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" @@ -28487,7 +29067,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 67 /* Identifier */); + ts.Debug.assert(bindingElement.name.kind === 69 /* Identifier */); // If the node is just an identifier, we will simply emit the text associated with the node's name // Example: // original: function foo({y = 10, x}) {} @@ -28503,40 +29083,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 211 /* FunctionDeclaration */: - case 216 /* ModuleDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 213 /* InterfaceDeclaration */: - case 212 /* ClassDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 215 /* EnumDeclaration */: + case 213 /* FunctionDeclaration */: + case 218 /* ModuleDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 215 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 217 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return emitExportDeclaration(node); - case 142 /* Constructor */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 144 /* Constructor */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return writeFunctionDeclaration(node); - case 146 /* ConstructSignature */: - case 145 /* CallSignature */: - case 147 /* IndexSignature */: + case 148 /* ConstructSignature */: + case 147 /* CallSignature */: + case 149 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return emitAccessorDeclaration(node); - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return emitPropertyDeclaration(node); - case 245 /* EnumMember */: + case 247 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return emitExportAssignment(node); - case 246 /* SourceFile */: + case 248 /* SourceFile */: return emitSourceFile(node); } } @@ -28587,6 +29167,261 @@ var ts; return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); } ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; + var entities = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; // Flags enum to track count of temp variables and a few dedicated names var TempFlags; (function (TempFlags) { @@ -28599,7 +29434,7 @@ var ts; // emit output for the __extends helper function var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; // emit output for the __decorate helper function - var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; + var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; // emit output for the __metadata helper function var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; // emit output for the __param helper function @@ -28607,6 +29442,7 @@ var ts; var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0 /* ES3 */; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */; var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var diagnostics = []; var newLine = host.getNewLine(); @@ -28711,6 +29547,14 @@ var ts; var sourceMapData; /** If removeComments is true, no leading-comments needed to be emitted **/ var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; + var moduleEmitDelegates = (_a = {}, + _a[5 /* ES6 */] = emitES6Module, + _a[2 /* AMD */] = emitAMDModule, + _a[4 /* System */] = emitSystemModule, + _a[3 /* UMD */] = emitUMDModule, + _a[1 /* CommonJS */] = emitCommonJSModule, + _a + ); if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { initializeEmitterWithSourceMaps(); } @@ -28798,19 +29642,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: return makeUniqueName(node.text); - case 216 /* ModuleDeclaration */: - case 215 /* EnumDeclaration */: + case 218 /* ModuleDeclaration */: + case 217 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 220 /* ImportDeclaration */: - case 226 /* ExportDeclaration */: + case 222 /* ImportDeclaration */: + case 228 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 211 /* FunctionDeclaration */: - case 212 /* ClassDeclaration */: - case 225 /* ExportAssignment */: + case 213 /* FunctionDeclaration */: + case 214 /* ClassDeclaration */: + case 227 /* ExportAssignment */: return generateNameForExportDefault(); - case 184 /* ClassExpression */: + case 186 /* ClassExpression */: return generateNameForClassExpression(); } } @@ -28982,7 +29826,7 @@ var ts; // unless it is a computed property. Then it is shown with brackets, // but the brackets are included in the name. var name_21 = node.name; - if (!name_21 || name_21.kind !== 134 /* ComputedPropertyName */) { + if (!name_21 || name_21.kind !== 136 /* ComputedPropertyName */) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -29000,20 +29844,20 @@ var ts; // The scope was already given a name use it recordScopeNameStart(scopeName); } - else if (node.kind === 211 /* FunctionDeclaration */ || - node.kind === 171 /* FunctionExpression */ || - node.kind === 141 /* MethodDeclaration */ || - node.kind === 140 /* MethodSignature */ || - node.kind === 143 /* GetAccessor */ || - node.kind === 144 /* SetAccessor */ || - node.kind === 216 /* ModuleDeclaration */ || - node.kind === 212 /* ClassDeclaration */ || - node.kind === 215 /* EnumDeclaration */) { + else if (node.kind === 213 /* FunctionDeclaration */ || + node.kind === 173 /* FunctionExpression */ || + node.kind === 143 /* MethodDeclaration */ || + node.kind === 142 /* MethodSignature */ || + node.kind === 145 /* GetAccessor */ || + node.kind === 146 /* SetAccessor */ || + node.kind === 218 /* ModuleDeclaration */ || + node.kind === 214 /* ClassDeclaration */ || + node.kind === 217 /* EnumDeclaration */) { // Declaration and has associated name use it if (node.name) { var name_22 = node.name; // For computed property names, the text will include the brackets - scopeName = name_22.kind === 134 /* ComputedPropertyName */ + scopeName = name_22.kind === 136 /* ComputedPropertyName */ ? ts.getTextOfNode(name_22) : node.name.text; } @@ -29125,7 +29969,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node); } - if (node.kind !== 246 /* SourceFile */) { + if (node.kind !== 248 /* SourceFile */) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); @@ -29153,7 +29997,7 @@ var ts; } // Create a temporary variable with a unique unused name. function createTempVariable(flags) { - var result = ts.createSynthesizedNode(67 /* Identifier */); + var result = ts.createSynthesizedNode(69 /* Identifier */); result.text = makeTempVariableName(flags); return result; } @@ -29398,10 +30242,10 @@ var ts; write("("); emit(tempVariable); // Now we emit the expressions - if (node.template.kind === 181 /* TemplateExpression */) { + if (node.template.kind === 183 /* TemplateExpression */) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 179 /* BinaryExpression */ + var needsParens = templateSpan.expression.kind === 181 /* BinaryExpression */ && templateSpan.expression.operatorToken.kind === 24 /* CommaToken */; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -29436,7 +30280,7 @@ var ts; // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== 170 /* ParenthesizedExpression */ + var needsParens = templateSpan.expression.kind !== 172 /* ParenthesizedExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; if (i > 0 || headEmitted) { // If this is the first span and the head was not emitted, then this templateSpan's @@ -29478,11 +30322,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: return parent.expression === template; - case 168 /* TaggedTemplateExpression */: - case 170 /* ParenthesizedExpression */: + case 170 /* TaggedTemplateExpression */: + case 172 /* ParenthesizedExpression */: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -29503,11 +30347,11 @@ var ts; // TODO (drosen): Note that we need to account for the upcoming 'yield' and // spread ('...') unary operators that are anticipated for ES6. switch (expression.kind) { - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: switch (expression.operatorToken.kind) { case 37 /* AsteriskToken */: - case 38 /* SlashToken */: - case 39 /* PercentToken */: + case 39 /* SlashToken */: + case 40 /* PercentToken */: return 1 /* GreaterThan */; case 35 /* PlusToken */: case 36 /* MinusToken */: @@ -29515,8 +30359,8 @@ var ts; default: return -1 /* LessThan */; } - case 182 /* YieldExpression */: - case 180 /* ConditionalExpression */: + case 184 /* YieldExpression */: + case 182 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -29531,7 +30375,7 @@ var ts; /// Emit a tag name, which is either '"div"' for lower-cased names, or /// 'Div' for upper-cased or dotted names function emitTagName(name) { - if (name.kind === 67 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { + if (name.kind === 69 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { write("\""); emit(name); write("\""); @@ -29565,8 +30409,8 @@ var ts; } } function emitJsxElement(openingNode, children) { - var syntheticReactRef = ts.createSynthesizedNode(67 /* Identifier */); - syntheticReactRef.text = 'React'; + var syntheticReactRef = ts.createSynthesizedNode(69 /* Identifier */); + syntheticReactRef.text = "React"; syntheticReactRef.parent = openingNode; // Call React.createElement(tag, ... emitLeadingComments(openingNode); @@ -29583,12 +30427,12 @@ var ts; // Either emit one big object literal (no spread attribs), or // a call to React.__spread var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 237 /* JsxSpreadAttribute */; })) { + if (ts.forEach(attrs, function (attr) { return attr.kind === 239 /* JsxSpreadAttribute */; })) { emitExpressionIdentifier(syntheticReactRef); write(".__spread("); var haveOpenedObjectLiteral = false; for (var i_1 = 0; i_1 < attrs.length; i_1++) { - if (attrs[i_1].kind === 237 /* JsxSpreadAttribute */) { + if (attrs[i_1].kind === 239 /* JsxSpreadAttribute */) { // If this is the first argument, we need to emit a {} as the first argument if (i_1 === 0) { write("{}, "); @@ -29603,7 +30447,7 @@ var ts; emit(attrs[i_1].expression); } else { - ts.Debug.assert(attrs[i_1].kind === 236 /* JsxAttribute */); + ts.Debug.assert(attrs[i_1].kind === 238 /* JsxAttribute */); if (haveOpenedObjectLiteral) { write(", "); } @@ -29637,11 +30481,11 @@ var ts; if (children) { for (var i = 0; i < children.length; i++) { // Don't emit empty expressions - if (children[i].kind === 238 /* JsxExpression */ && !(children[i].expression)) { + if (children[i].kind === 240 /* JsxExpression */ && !(children[i].expression)) { continue; } // Don't emit empty strings - if (children[i].kind === 234 /* JsxText */) { + if (children[i].kind === 236 /* JsxText */) { var text = getTextToEmit(children[i]); if (text !== undefined) { write(", \""); @@ -29659,11 +30503,11 @@ var ts; write(")"); // closes "React.createElement(" emitTrailingComments(openingNode); } - if (node.kind === 231 /* JsxElement */) { + if (node.kind === 233 /* JsxElement */) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 234 /* JsxSelfClosingElement */); emitJsxElement(node); } } @@ -29685,11 +30529,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 237 /* JsxSpreadAttribute */) { + if (attribs[i].kind === 239 /* JsxSpreadAttribute */) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 236 /* JsxAttribute */); + ts.Debug.assert(attribs[i].kind === 238 /* JsxAttribute */); emitJsxAttribute(attribs[i]); } } @@ -29697,11 +30541,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 232 /* JsxSelfClosingElement */)) { + if (node.attributes.length > 0 || (node.kind === 234 /* JsxSelfClosingElement */)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 232 /* JsxSelfClosingElement */) { + if (node.kind === 234 /* JsxSelfClosingElement */) { write("/>"); } else { @@ -29720,11 +30564,11 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 231 /* JsxElement */) { + if (node.kind === 233 /* JsxElement */) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 234 /* JsxSelfClosingElement */); emitJsxOpeningOrSelfClosingElement(node); } } @@ -29732,11 +30576,11 @@ var ts; // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. // For example, this is utilized when feeding in a result to Object.defineProperty. function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 161 /* BindingElement */); + ts.Debug.assert(node.kind !== 163 /* BindingElement */); if (node.kind === 9 /* StringLiteral */) { emitLiteral(node); } - else if (node.kind === 134 /* ComputedPropertyName */) { + else if (node.kind === 136 /* ComputedPropertyName */) { // if this is a decorated computed property, we will need to capture the result // of the property expression so that we can apply decorators later. This is to ensure // we don't introduce unintended side effects: @@ -29747,7 +30591,7 @@ var ts; // // The emit for the decorated computed property decorator is: // - // Object.defineProperty(C.prototype, _a, __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a))); + // __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a)); // if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { @@ -29780,60 +30624,61 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 162 /* ArrayLiteralExpression */: - case 179 /* BinaryExpression */: - case 166 /* CallExpression */: - case 239 /* CaseClause */: - case 134 /* ComputedPropertyName */: - case 180 /* ConditionalExpression */: - case 137 /* Decorator */: - case 173 /* DeleteExpression */: - case 195 /* DoStatement */: - case 165 /* ElementAccessExpression */: - case 225 /* ExportAssignment */: - case 193 /* ExpressionStatement */: - case 186 /* ExpressionWithTypeArguments */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 194 /* IfStatement */: - case 232 /* JsxSelfClosingElement */: - case 233 /* JsxOpeningElement */: - case 237 /* JsxSpreadAttribute */: - case 238 /* JsxExpression */: - case 167 /* NewExpression */: - case 170 /* ParenthesizedExpression */: - case 178 /* PostfixUnaryExpression */: - case 177 /* PrefixUnaryExpression */: - case 202 /* ReturnStatement */: - case 244 /* ShorthandPropertyAssignment */: - case 183 /* SpreadElementExpression */: - case 204 /* SwitchStatement */: - case 168 /* TaggedTemplateExpression */: - case 188 /* TemplateSpan */: - case 206 /* ThrowStatement */: - case 169 /* TypeAssertionExpression */: - case 174 /* TypeOfExpression */: - case 175 /* VoidExpression */: - case 196 /* WhileStatement */: - case 203 /* WithStatement */: - case 182 /* YieldExpression */: + case 164 /* ArrayLiteralExpression */: + case 189 /* AsExpression */: + case 181 /* BinaryExpression */: + case 168 /* CallExpression */: + case 241 /* CaseClause */: + case 136 /* ComputedPropertyName */: + case 182 /* ConditionalExpression */: + case 139 /* Decorator */: + case 175 /* DeleteExpression */: + case 197 /* DoStatement */: + case 167 /* ElementAccessExpression */: + case 227 /* ExportAssignment */: + case 195 /* ExpressionStatement */: + case 188 /* ExpressionWithTypeArguments */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 196 /* IfStatement */: + case 234 /* JsxSelfClosingElement */: + case 235 /* JsxOpeningElement */: + case 239 /* JsxSpreadAttribute */: + case 240 /* JsxExpression */: + case 169 /* NewExpression */: + case 172 /* ParenthesizedExpression */: + case 180 /* PostfixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: + case 204 /* ReturnStatement */: + case 246 /* ShorthandPropertyAssignment */: + case 185 /* SpreadElementExpression */: + case 206 /* SwitchStatement */: + case 170 /* TaggedTemplateExpression */: + case 190 /* TemplateSpan */: + case 208 /* ThrowStatement */: + case 171 /* TypeAssertionExpression */: + case 176 /* TypeOfExpression */: + case 177 /* VoidExpression */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 184 /* YieldExpression */: return true; - case 161 /* BindingElement */: - case 245 /* EnumMember */: - case 136 /* Parameter */: - case 243 /* PropertyAssignment */: - case 139 /* PropertyDeclaration */: - case 209 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 247 /* EnumMember */: + case 138 /* Parameter */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 211 /* VariableDeclaration */: return parent.initializer === node; - case 164 /* PropertyAccessExpression */: + case 166 /* PropertyAccessExpression */: return parent.expression === node; - case 172 /* ArrowFunction */: - case 171 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 173 /* FunctionExpression */: return parent.body === node; - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: return parent.moduleReference === node; - case 133 /* QualifiedName */: + case 135 /* QualifiedName */: return parent.left === node; } return false; @@ -29845,9 +30690,9 @@ var ts; } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 246 /* SourceFile */) { + if (container.kind === 248 /* SourceFile */) { // Identifier references module export - if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { + if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { write("exports."); } } @@ -29857,20 +30702,20 @@ var ts; write("."); } } - else if (languageVersion < 2 /* ES6 */) { + else if (modulekind !== 5 /* ES6 */) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 221 /* ImportClause */) { + if (declaration.kind === 223 /* ImportClause */) { // Identifier references default import write(getGeneratedNameForNode(declaration.parent)); write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 224 /* ImportSpecifier */) { + else if (declaration.kind === 226 /* ImportSpecifier */) { // Identifier references named import write(getGeneratedNameForNode(declaration.parent.parent.parent)); - var name = declaration.propertyName || declaration.name; - var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name); + var name_23 = declaration.propertyName || declaration.name; + var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name_23); if (languageVersion === 0 /* ES3 */ && identifier === "default") { write("[\"default\"]"); } @@ -29898,10 +30743,10 @@ var ts; if (languageVersion < 2 /* ES6 */) { var parent_6 = node.parent; switch (parent_6.kind) { - case 161 /* BindingElement */: - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: - case 209 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 211 /* VariableDeclaration */: return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); } } @@ -29979,7 +30824,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(112 /* YieldKeyword */)); + write(ts.tokenToString(114 /* YieldKeyword */)); if (node.asteriskToken) { write("*"); } @@ -29993,7 +30838,7 @@ var ts; if (needsParenthesis) { write("("); } - write(ts.tokenToString(112 /* YieldKeyword */)); + write(ts.tokenToString(114 /* YieldKeyword */)); write(" "); emit(node.expression); if (needsParenthesis) { @@ -30001,22 +30846,22 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 179 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 181 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 180 /* ConditionalExpression */ && node.parent.condition === node) { + else if (node.parent.kind === 182 /* ConditionalExpression */ && node.parent.condition === node) { return true; } return false; } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 67 /* Identifier */: - case 162 /* ArrayLiteralExpression */: - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: - case 166 /* CallExpression */: - case 170 /* ParenthesizedExpression */: + case 69 /* Identifier */: + case 164 /* ArrayLiteralExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 172 /* ParenthesizedExpression */: // This list is not exhaustive and only includes those cases that are relevant // to the check in emitArrayLiteral. More cases can be added as needed. return false; @@ -30036,17 +30881,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 183 /* SpreadElementExpression */) { + if (e.kind === 185 /* SpreadElementExpression */) { e = e.expression; emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162 /* ArrayLiteralExpression */) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 164 /* ArrayLiteralExpression */) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 183 /* SpreadElementExpression */) { + while (i < length && elements[i].kind !== 185 /* SpreadElementExpression */) { i++; } write("["); @@ -30069,7 +30914,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 183 /* SpreadElementExpression */; + return node.kind === 185 /* SpreadElementExpression */; } function emitArrayLiteral(node) { var elements = node.elements; @@ -30139,7 +30984,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 143 /* GetAccessor */ || property.kind === 144 /* SetAccessor */) { + if (property.kind === 145 /* GetAccessor */ || property.kind === 146 /* SetAccessor */) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { @@ -30191,13 +31036,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 243 /* PropertyAssignment */) { + if (property.kind === 245 /* PropertyAssignment */) { emit(property.initializer); } - else if (property.kind === 244 /* ShorthandPropertyAssignment */) { + else if (property.kind === 246 /* ShorthandPropertyAssignment */) { emitExpressionIdentifier(property.name); } - else if (property.kind === 141 /* MethodDeclaration */) { + else if (property.kind === 143 /* MethodDeclaration */) { emitFunctionDeclaration(property); } else { @@ -30231,7 +31076,7 @@ var ts; // Everything until that point can be emitted as part of the initial object literal. var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 134 /* ComputedPropertyName */) { + if (properties[i].name.kind === 136 /* ComputedPropertyName */) { numInitialNonComputedProperties = i; break; } @@ -30247,21 +31092,21 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(179 /* BinaryExpression */, startsOnNewLine); + var result = ts.createSynthesizedNode(181 /* BinaryExpression */, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(164 /* PropertyAccessExpression */); + var result = ts.createSynthesizedNode(166 /* PropertyAccessExpression */); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(21 /* DotToken */); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(165 /* ElementAccessExpression */); + var result = ts.createSynthesizedNode(167 /* ElementAccessExpression */); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; @@ -30269,7 +31114,7 @@ var ts; function parenthesizeForAccess(expr) { // When diagnosing whether the expression needs parentheses, the decision should be based // on the innermost expression in a chain of nested type assertions. - while (expr.kind === 169 /* TypeAssertionExpression */ || expr.kind === 187 /* AsExpression */) { + while (expr.kind === 171 /* TypeAssertionExpression */ || expr.kind === 189 /* AsExpression */) { expr = expr.expression; } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary @@ -30281,11 +31126,11 @@ var ts; // 1.x -> not the same as (1).x // if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 167 /* NewExpression */ && + expr.kind !== 169 /* NewExpression */ && expr.kind !== 8 /* NumericLiteral */) { return expr; } - var node = ts.createSynthesizedNode(170 /* ParenthesizedExpression */); + var node = ts.createSynthesizedNode(172 /* ParenthesizedExpression */); node.expression = expr; return node; } @@ -30320,7 +31165,7 @@ var ts; // Return true if identifier resolves to an exported member of a namespace function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 246 /* SourceFile */; + return container && container.kind !== 248 /* SourceFile */; } function emitShorthandPropertyAssignment(node) { // The name property of a short-hand property assignment is considered an expression position, so here @@ -30340,13 +31185,17 @@ var ts; write(": "); emit(node.name); } + if (languageVersion >= 2 /* ES6 */ && node.objectAssignmentInitializer) { + write(" = "); + emit(node.objectAssignmentInitializer); + } } function tryEmitConstantValue(node) { var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 164 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 166 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -30357,7 +31206,7 @@ var ts; if (compilerOptions.isolatedModules) { return undefined; } - return node.kind === 164 /* PropertyAccessExpression */ || node.kind === 165 /* ElementAccessExpression */ + return node.kind === 166 /* PropertyAccessExpression */ || node.kind === 167 /* ElementAccessExpression */ ? resolver.getConstantValue(node) : undefined; } @@ -30418,7 +31267,7 @@ var ts; emit(node.right); } function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 67 /* Identifier */) { + if (node.left.kind === 69 /* Identifier */) { emitEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -30438,7 +31287,7 @@ var ts; } function emitEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: if (useFallback) { write("typeof "); emitExpressionIdentifier(node); @@ -30446,7 +31295,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 133 /* QualifiedName */: + case 135 /* QualifiedName */: emitQualifiedNameAsExpression(node, useFallback); break; } @@ -30461,16 +31310,16 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 183 /* SpreadElementExpression */; }); + return ts.forEach(elements, function (e) { return e.kind === 185 /* SpreadElementExpression */; }); } function skipParentheses(node) { - while (node.kind === 170 /* ParenthesizedExpression */ || node.kind === 169 /* TypeAssertionExpression */ || node.kind === 187 /* AsExpression */) { + while (node.kind === 172 /* ParenthesizedExpression */ || node.kind === 171 /* TypeAssertionExpression */ || node.kind === 189 /* AsExpression */) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 67 /* Identifier */ || node.kind === 95 /* ThisKeyword */ || node.kind === 93 /* SuperKeyword */) { + if (node.kind === 69 /* Identifier */ || node.kind === 97 /* ThisKeyword */ || node.kind === 95 /* SuperKeyword */) { emit(node); return node; } @@ -30485,20 +31334,20 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 164 /* PropertyAccessExpression */) { + if (expr.kind === 166 /* PropertyAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 165 /* ElementAccessExpression */) { + else if (expr.kind === 167 /* ElementAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 93 /* SuperKeyword */) { + else if (expr.kind === 95 /* SuperKeyword */) { target = expr; write("_super"); } @@ -30507,7 +31356,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 93 /* SuperKeyword */) { + if (target.kind === 95 /* SuperKeyword */) { // Calls of form super(...) and super.foo(...) emitThis(target); } @@ -30530,13 +31379,13 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 93 /* SuperKeyword */) { + if (node.expression.kind === 95 /* SuperKeyword */) { emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 164 /* PropertyAccessExpression */ && node.expression.expression.kind === 93 /* SuperKeyword */; + superCall = node.expression.kind === 166 /* PropertyAccessExpression */ && node.expression.expression.kind === 95 /* SuperKeyword */; } if (superCall && languageVersion < 2 /* ES6 */) { write(".call("); @@ -30605,12 +31454,12 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172 /* ArrowFunction */) { - if (node.expression.kind === 169 /* TypeAssertionExpression */ || node.expression.kind === 187 /* AsExpression */) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 174 /* ArrowFunction */) { + if (node.expression.kind === 171 /* TypeAssertionExpression */ || node.expression.kind === 189 /* AsExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind === 169 /* TypeAssertionExpression */ || operand.kind === 187 /* AsExpression */) { + while (operand.kind === 171 /* TypeAssertionExpression */ || operand.kind === 189 /* AsExpression */) { operand = operand.expression; } // We have an expression of the form: (SubExpr) @@ -30621,15 +31470,15 @@ var ts; // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() // new (A()) should be emitted as new (A()) and not new A() // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () - if (operand.kind !== 177 /* PrefixUnaryExpression */ && - operand.kind !== 175 /* VoidExpression */ && - operand.kind !== 174 /* TypeOfExpression */ && - operand.kind !== 173 /* DeleteExpression */ && - operand.kind !== 178 /* PostfixUnaryExpression */ && - operand.kind !== 167 /* NewExpression */ && - !(operand.kind === 166 /* CallExpression */ && node.parent.kind === 167 /* NewExpression */) && - !(operand.kind === 171 /* FunctionExpression */ && node.parent.kind === 166 /* CallExpression */) && - !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 164 /* PropertyAccessExpression */)) { + if (operand.kind !== 179 /* PrefixUnaryExpression */ && + operand.kind !== 177 /* VoidExpression */ && + operand.kind !== 176 /* TypeOfExpression */ && + operand.kind !== 175 /* DeleteExpression */ && + operand.kind !== 180 /* PostfixUnaryExpression */ && + operand.kind !== 169 /* NewExpression */ && + !(operand.kind === 168 /* CallExpression */ && node.parent.kind === 169 /* NewExpression */) && + !(operand.kind === 173 /* FunctionExpression */ && node.parent.kind === 168 /* CallExpression */) && + !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 166 /* PropertyAccessExpression */)) { emit(operand); return; } @@ -30640,25 +31489,25 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(76 /* DeleteKeyword */)); + write(ts.tokenToString(78 /* DeleteKeyword */)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(101 /* VoidKeyword */)); + write(ts.tokenToString(103 /* VoidKeyword */)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(99 /* TypeOfKeyword */)); + write(ts.tokenToString(101 /* TypeOfKeyword */)); write(" "); emit(node.expression); } function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 67 /* Identifier */ || ts.nodeIsSynthesized(node)) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 69 /* Identifier */ || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 /* VariableDeclaration */ || node.parent.kind === 161 /* BindingElement */); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 211 /* VariableDeclaration */ || node.parent.kind === 163 /* BindingElement */); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -30688,12 +31537,12 @@ var ts; // the resulting expression a prefix increment operation. And in the second, it will make the resulting // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. - if (node.operand.kind === 177 /* PrefixUnaryExpression */) { + if (node.operand.kind === 179 /* PrefixUnaryExpression */) { var operand = node.operand; - if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 40 /* PlusPlusToken */)) { + if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 41 /* PlusPlusToken */)) { write(" "); } - else if (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 41 /* MinusMinusToken */)) { + else if (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 42 /* MinusMinusToken */)) { write(" "); } } @@ -30713,7 +31562,7 @@ var ts; write("\", "); write(ts.tokenToString(node.operator)); emit(node.operand); - if (node.operator === 40 /* PlusPlusToken */) { + if (node.operator === 41 /* PlusPlusToken */) { write(") - 1)"); } else { @@ -30744,10 +31593,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 246 /* SourceFile */) { + if (current.kind === 248 /* SourceFile */) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 217 /* ModuleBlock */) { + else if (ts.isFunctionLike(current) || current.kind === 219 /* ModuleBlock */) { return false; } else { @@ -30755,14 +31604,69 @@ var ts; } } } + /** + * Emit ES7 exponentiation operator downlevel using Math.pow + * @param node a binary expression node containing exponentiationOperator (**, **=) + */ + function emitExponentiationOperator(node) { + var leftHandSideExpression = node.left; + if (node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { + var synthesizedLHS; + var shouldEmitParentheses = false; + if (ts.isElementAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(167 /* ElementAccessExpression */, /*startsOnNewLine*/ false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldEmitCommaBeforeAssignment*/ false); + synthesizedLHS.expression = identifier; + if (leftHandSideExpression.argumentExpression.kind !== 8 /* NumericLiteral */ && + leftHandSideExpression.argumentExpression.kind !== 9 /* StringLiteral */) { + var tempArgumentExpression = createAndRecordTempVariable(268435456 /* _i */); + synthesizedLHS.argumentExpression = tempArgumentExpression; + emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, /*shouldEmitCommaBeforeAssignment*/ true); + } + else { + synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; + } + write(", "); + } + else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(166 /* PropertyAccessExpression */, /*startsOnNewLine*/ false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldemitCommaBeforeAssignment*/ false); + synthesizedLHS.expression = identifier; + synthesizedLHS.dotToken = leftHandSideExpression.dotToken; + synthesizedLHS.name = leftHandSideExpression.name; + write(", "); + } + emit(synthesizedLHS || leftHandSideExpression); + write(" = "); + write("Math.pow("); + emit(synthesizedLHS || leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + if (shouldEmitParentheses) { + write(")"); + } + } + else { + write("Math.pow("); + emit(leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + } + } function emitBinaryExpression(node) { - if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 55 /* EqualsToken */ && - (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 193 /* ExpressionStatement */); + if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 56 /* EqualsToken */ && + (node.left.kind === 165 /* ObjectLiteralExpression */ || node.left.kind === 164 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 195 /* ExpressionStatement */); } else { - var exportChanged = node.operatorToken.kind >= 55 /* FirstAssignment */ && - node.operatorToken.kind <= 66 /* LastAssignment */ && + var exportChanged = node.operatorToken.kind >= 56 /* FirstAssignment */ && + node.operatorToken.kind <= 68 /* LastAssignment */ && isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); if (exportChanged) { // emit assignment 'x y' as 'exports("x", x y)' @@ -30770,12 +31674,25 @@ var ts; emitNodeWithoutSourceMap(node.left); write("\", "); } - emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 /* CommaToken */ ? " " : undefined); - write(ts.tokenToString(node.operatorToken.kind)); - var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); - emit(node.right); - decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + if (node.operatorToken.kind === 38 /* AsteriskAsteriskToken */ || node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { + // Downleveled emit exponentiation operator using Math.pow + emitExponentiationOperator(node); + } + else { + emit(node.left); + // Add indentation before emit the operator if the operator is on different line + // For example: + // 3 + // + 2; + // emitted as + // 3 + // + 2; + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 /* CommaToken */ ? " " : undefined); + write(ts.tokenToString(node.operatorToken.kind)); + var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); + emit(node.right); + decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + } if (exportChanged) { write(")"); } @@ -30810,7 +31727,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 190 /* Block */) { + if (node && node.kind === 192 /* Block */) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -30825,12 +31742,12 @@ var ts; emitToken(15 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 217 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 216 /* ModuleDeclaration */); + if (node.kind === 219 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 218 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 217 /* ModuleBlock */) { + if (node.kind === 219 /* ModuleBlock */) { emitTempDeclarations(/*newLine*/ true); } decreaseIndent(); @@ -30839,7 +31756,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 190 /* Block */) { + if (node.kind === 192 /* Block */) { write(" "); emit(node); } @@ -30851,11 +31768,11 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 172 /* ArrowFunction */); + emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 174 /* ArrowFunction */); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(86 /* IfKeyword */, node.pos); + var endPos = emitToken(88 /* IfKeyword */, node.pos); write(" "); endPos = emitToken(17 /* OpenParenToken */, endPos); emit(node.expression); @@ -30863,8 +31780,8 @@ var ts; emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(78 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 194 /* IfStatement */) { + emitToken(80 /* ElseKeyword */, node.thenStatement.end); + if (node.elseStatement.kind === 196 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -30876,7 +31793,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 190 /* Block */) { + if (node.statement.kind === 192 /* Block */) { write(" "); } else { @@ -30902,13 +31819,13 @@ var ts; // variables in variable declaration list were already hoisted return false; } - var tokenKind = 100 /* VarKeyword */; + var tokenKind = 102 /* VarKeyword */; if (decl && languageVersion >= 2 /* ES6 */) { if (ts.isLet(decl)) { - tokenKind = 106 /* LetKeyword */; + tokenKind = 108 /* LetKeyword */; } else if (ts.isConst(decl)) { - tokenKind = 72 /* ConstKeyword */; + tokenKind = 74 /* ConstKeyword */; } } if (startPos !== undefined) { @@ -30917,13 +31834,13 @@ var ts; } else { switch (tokenKind) { - case 100 /* VarKeyword */: + case 102 /* VarKeyword */: write("var "); break; - case 106 /* LetKeyword */: + case 108 /* LetKeyword */: write("let "); break; - case 72 /* ConstKeyword */: + case 74 /* ConstKeyword */: write("const "); break; } @@ -30948,10 +31865,10 @@ var ts; return started; } function emitForStatement(node) { - var endPos = emitToken(84 /* ForKeyword */, node.pos); + var endPos = emitToken(86 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(17 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 212 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -30972,13 +31889,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 199 /* ForOfStatement */) { + if (languageVersion < 2 /* ES6 */ && node.kind === 201 /* ForOfStatement */) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(84 /* ForKeyword */, node.pos); + var endPos = emitToken(86 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(17 /* OpenParenToken */, endPos); - if (node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer.kind === 212 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -30988,7 +31905,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 198 /* ForInStatement */) { + if (node.kind === 200 /* ForInStatement */) { write(" in "); } else { @@ -31019,7 +31936,7 @@ var ts; // 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(84 /* ForKeyword */, node.pos); + var endPos = emitToken(86 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(17 /* OpenParenToken */, endPos); // Do not emit the LHS let declaration yet, because it might contain destructuring. @@ -31030,7 +31947,7 @@ var ts; // for (let v of arr) { } // // we don't want to emit a temporary variable for the RHS, just use it directly. - var rhsIsIdentifier = node.expression.kind === 67 /* Identifier */; + var rhsIsIdentifier = node.expression.kind === 69 /* Identifier */; var counter = createTempVariable(268435456 /* _i */); var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); // This is the let keyword for the counter and rhsReference. The let keyword for @@ -31073,7 +31990,7 @@ var ts; // let v = _a[_i]; var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer.kind === 212 /* VariableDeclarationList */) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -31102,8 +32019,8 @@ var ts; else { // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. - var assignmentExpression = createBinaryExpression(node.initializer, 55 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); - if (node.initializer.kind === 162 /* ArrayLiteralExpression */ || node.initializer.kind === 163 /* ObjectLiteralExpression */) { + var assignmentExpression = createBinaryExpression(node.initializer, 56 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); + if (node.initializer.kind === 164 /* ArrayLiteralExpression */ || node.initializer.kind === 165 /* ObjectLiteralExpression */) { // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined); @@ -31114,7 +32031,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 190 /* Block */) { + if (node.statement.kind === 192 /* Block */) { emitLines(node.statement.statements); } else { @@ -31126,12 +32043,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 203 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(92 /* ReturnKeyword */, node.pos); + emitToken(94 /* ReturnKeyword */, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -31142,7 +32059,7 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(94 /* SwitchKeyword */, node.pos); + var endPos = emitToken(96 /* SwitchKeyword */, node.pos); write(" "); emitToken(17 /* OpenParenToken */, endPos); emit(node.expression); @@ -31171,7 +32088,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 239 /* CaseClause */) { + if (node.kind === 241 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -31206,7 +32123,7 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(70 /* CatchKeyword */, node.pos); + var endPos = emitToken(72 /* CatchKeyword */, node.pos); write(" "); emitToken(17 /* OpenParenToken */, endPos); emit(node.variableDeclaration); @@ -31215,7 +32132,7 @@ var ts; emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(74 /* DebuggerKeyword */, node.pos); + emitToken(76 /* DebuggerKeyword */, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -31226,7 +32143,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 216 /* ModuleDeclaration */); + } while (node && node.kind !== 218 /* ModuleDeclaration */); return node; } function emitContainingModuleName(node) { @@ -31241,7 +32158,7 @@ var ts; write(getGeneratedNameForNode(container)); write("."); } - else if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { + else if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { write("exports."); } } @@ -31251,15 +32168,15 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(8 /* NumericLiteral */); zero.text = "0"; - var result = ts.createSynthesizedNode(175 /* VoidExpression */); + var result = ts.createSynthesizedNode(177 /* VoidExpression */); result.expression = zero; return result; } function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 246 /* SourceFile */) { - ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 225 /* ExportAssignment */); + if (node.parent.kind === 248 /* SourceFile */) { + ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 227 /* ExportAssignment */); // only allow export default at a source file level - if (compilerOptions.module === 1 /* CommonJS */ || compilerOptions.module === 2 /* AMD */ || compilerOptions.module === 3 /* UMD */) { + if (modulekind === 1 /* CommonJS */ || modulekind === 2 /* AMD */ || modulekind === 3 /* UMD */) { if (!currentSourceFile.symbol.exports["___esModule"]) { if (languageVersion === 1 /* ES5 */) { // default value of configurable, enumerable, writable are `false`. @@ -31279,7 +32196,7 @@ var ts; writeLine(); emitStart(node); // emit call to exporter only for top level nodes - if (compilerOptions.module === 4 /* System */ && node.parent === currentSourceFile) { + if (modulekind === 4 /* System */ && node.parent === currentSourceFile) { // emit export default as // export("default", ) write(exportFunctionForFile + "(\""); @@ -31314,7 +32231,7 @@ var ts; } } function emitExportMemberAssignments(name) { - if (compilerOptions.module === 4 /* System */) { + if (modulekind === 4 /* System */) { return; } if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { @@ -31333,7 +32250,7 @@ var ts; } } function emitExportSpecifierInSystemModule(specifier) { - ts.Debug.assert(compilerOptions.module === 4 /* System */); + ts.Debug.assert(modulekind === 4 /* System */); if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { return; } @@ -31347,6 +32264,49 @@ var ts; emitEnd(specifier.name); write(";"); } + /** + * Emit an assignment to a given identifier, 'name', with a given expression, 'value'. + * @param name an identifier as a left-hand-side operand of the assignment + * @param value an expression as a right-hand-side operand of the assignment + * @param shouldEmitCommaBeforeAssignment a boolean indicating whether to prefix an assignment with comma + */ + function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { + if (shouldEmitCommaBeforeAssignment) { + write(", "); + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(name); + write("\", "); + } + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 211 /* VariableDeclaration */ || name.parent.kind === 163 /* BindingElement */); + if (isVariableDeclarationOrBindingElement) { + emitModuleMemberName(name.parent); + } + else { + emit(name); + } + write(" = "); + emit(value); + if (exportChanged) { + write(")"); + } + } + /** + * Create temporary variable, emit an assignment of the variable the given expression + * @param expression an expression to assign to the newly created temporary variable + * @param canDefineTempVariablesInPlace a boolean indicating whether you can define the temporary variable at an assignment location + * @param shouldEmitCommaBeforeAssignment a boolean indicating whether an assignment should prefix with comma + */ + function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { + var identifier = createTempVariable(0 /* Auto */); + if (!canDefineTempVariablesInPlace) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); + return identifier; + } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; // An exported declaration is actually emitted as an assignment (to a property on the module object), so @@ -31354,44 +32314,21 @@ var ts; // Also temporary variables should be explicitly allocated for source level declarations when module target is system // because actual variable declarations are hoisted var canDefineTempVariablesInPlace = false; - if (root.kind === 209 /* VariableDeclaration */) { + if (root.kind === 211 /* VariableDeclaration */) { var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 136 /* Parameter */) { + else if (root.kind === 138 /* Parameter */) { canDefineTempVariablesInPlace = true; } - if (root.kind === 179 /* BinaryExpression */) { + if (root.kind === 181 /* BinaryExpression */) { emitAssignmentExpression(root); } else { ts.Debug.assert(!isAssignmentExpressionStatement); emitBindingElement(root, value); } - function emitAssignment(name, value) { - if (emitCount++) { - write(", "); - } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 /* VariableDeclaration */ || name.parent.kind === 161 /* BindingElement */); - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(name); - write("\", "); - } - if (isVariableDeclarationOrBindingElement) { - emitModuleMemberName(name.parent); - } - else { - emit(name); - } - write(" = "); - emit(value); - if (exportChanged) { - write(")"); - } - } /** * Ensures that there exists a declared identifier whose value holds the given expression. * This function is useful to ensure that the expression's value can be read from in subsequent expressions. @@ -31402,14 +32339,11 @@ var ts; * false if it is necessary to always emit an identifier. */ function ensureIdentifier(expr, reuseIdentifierExpressions) { - if (expr.kind === 67 /* Identifier */ && reuseIdentifierExpressions) { + if (expr.kind === 69 /* Identifier */ && reuseIdentifierExpressions) { return expr; } - var identifier = createTempVariable(0 /* Auto */); - if (!canDefineTempVariablesInPlace) { - recordTempDeclaration(identifier); - } - emitAssignment(identifier, expr); + var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); + emitCount++; return identifier; } function createDefaultValueCheck(value, defaultValue) { @@ -31417,18 +32351,18 @@ var ts; // we need to generate a temporary variable value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(179 /* BinaryExpression */); + var equals = ts.createSynthesizedNode(181 /* BinaryExpression */); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(32 /* EqualsEqualsEqualsToken */); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(180 /* ConditionalExpression */); + var cond = ts.createSynthesizedNode(182 /* ConditionalExpression */); cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(52 /* QuestionToken */); + cond.questionToken = ts.createSynthesizedNode(53 /* QuestionToken */); cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(53 /* ColonToken */); + cond.colonToken = ts.createSynthesizedNode(54 /* ColonToken */); cond.whenFalse = whenFalse; return cond; } @@ -31442,14 +32376,14 @@ var ts; // otherwise occur when the identifier is emitted. var syntheticName = ts.createSynthesizedNode(propName.kind); syntheticName.text = propName.text; - if (syntheticName.kind !== 67 /* Identifier */) { + if (syntheticName.kind !== 69 /* Identifier */) { return createElementAccessExpression(object, syntheticName); } return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(166 /* CallExpression */); - var sliceIdentifier = ts.createSynthesizedNode(67 /* Identifier */); + var call = ts.createSynthesizedNode(168 /* CallExpression */); + var sliceIdentifier = ts.createSynthesizedNode(69 /* Identifier */); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); call.arguments = ts.createSynthesizedNodeArray(); @@ -31465,9 +32399,10 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) { + if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { var propName = p.name; - emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); + var target_1 = p.kind === 246 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; + emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); } } } @@ -31480,8 +32415,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 185 /* OmittedExpression */) { - if (e.kind !== 183 /* SpreadElementExpression */) { + if (e.kind !== 187 /* OmittedExpression */) { + if (e.kind !== 185 /* SpreadElementExpression */) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -31491,18 +32426,25 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) { + if (target.kind === 246 /* ShorthandPropertyAssignment */) { + if (target.objectAssignmentInitializer) { + value = createDefaultValueCheck(value, target.objectAssignmentInitializer); + } + target = target.name; + } + else if (target.kind === 181 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 163 /* ObjectLiteralExpression */) { + if (target.kind === 165 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 162 /* ArrayLiteralExpression */) { + else if (target.kind === 164 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value); } else { - emitAssignment(target, value); + emitAssignment(target, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0); + emitCount++; } } function emitAssignmentExpression(root) { @@ -31515,14 +32457,14 @@ var ts; emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 170 /* ParenthesizedExpression */) { + if (root.parent.kind !== 172 /* ParenthesizedExpression */) { write("("); } value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 170 /* ParenthesizedExpression */) { + if (root.parent.kind !== 172 /* ParenthesizedExpression */) { write(")"); } } @@ -31549,12 +32491,12 @@ var ts; } for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (pattern.kind === 159 /* ObjectBindingPattern */) { + if (pattern.kind === 161 /* ObjectBindingPattern */) { // Rewrite element to a declaration with an initializer that fetches property var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 185 /* OmittedExpression */) { + else if (element.kind !== 187 /* OmittedExpression */) { if (!element.dotDotDotToken) { // Rewrite element to a declaration that accesses array element at index i emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); @@ -31566,7 +32508,8 @@ var ts; } } else { - emitAssignment(target.name, value); + emitAssignment(target.name, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0); + emitCount++; } } } @@ -31593,8 +32536,8 @@ var ts; (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isUninitializedLet && - node.parent.parent.kind !== 198 /* ForInStatement */ && - node.parent.parent.kind !== 199 /* ForOfStatement */) { + node.parent.parent.kind !== 200 /* ForInStatement */ && + node.parent.parent.kind !== 201 /* ForOfStatement */) { initializer = createVoidZero(); } } @@ -31612,11 +32555,11 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 185 /* OmittedExpression */) { + if (node.kind === 187 /* OmittedExpression */) { return; } var name = node.name; - if (name.kind === 67 /* Identifier */) { + if (name.kind === 69 /* Identifier */) { emitExportMemberAssignments(name); } else if (ts.isBindingPattern(name)) { @@ -31624,15 +32567,15 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 209 /* VariableDeclaration */ && node.parent.kind !== 161 /* BindingElement */)) { + if (!node.parent || (node.parent.kind !== 211 /* VariableDeclaration */ && node.parent.kind !== 163 /* BindingElement */)) { return 0; } return ts.getCombinedNodeFlags(node.parent); } function isES6ExportedDeclaration(node) { return !!(node.flags & 1 /* Export */) && - languageVersion >= 2 /* ES6 */ && - node.parent.kind === 246 /* SourceFile */; + modulekind === 5 /* ES6 */ && + node.parent.kind === 248 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -31656,7 +32599,7 @@ var ts; write(";"); } } - if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile) { + if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); } } @@ -31683,12 +32626,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2 /* ES6 */) { if (ts.isBindingPattern(node.name)) { - var name_23 = createTempVariable(0 /* Auto */); + var name_24 = createTempVariable(0 /* Auto */); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_23); - emit(name_23); + tempParameters.push(name_24); + emit(name_24); } else { emit(node.name); @@ -31793,12 +32736,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 143 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 145 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 172 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + return node.kind === 174 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; } function emitDeclarationName(node) { if (node.name) { @@ -31809,11 +32752,11 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 171 /* FunctionExpression */) { + if (node.kind === 173 /* FunctionExpression */) { // Emit name if one is present return !!node.name; } - if (node.kind === 211 /* FunctionDeclaration */) { + if (node.kind === 213 /* FunctionDeclaration */) { // Emit name if one is present, or emit generated name in down-level case (for export default case) return !!node.name || languageVersion < 2 /* ES6 */; } @@ -31824,9 +32767,9 @@ var ts; } // TODO (yuisu) : we should not have special cases to condition emitting comments // but have one place to fix check for these conditions. - if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */ && - node.parent && node.parent.kind !== 243 /* PropertyAssignment */ && - node.parent.kind !== 166 /* CallExpression */) { + if (node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */ && + node.parent && node.parent.kind !== 245 /* PropertyAssignment */ && + node.parent.kind !== 168 /* CallExpression */) { // 1. Methods will emit the comments as part of emitting method declaration // 2. If the function is a property of object literal, emitting leading-comments // is done by emitNodeWithoutSourceMap which then call this function. @@ -31860,11 +32803,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 /* ES6 */ && node.kind === 211 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { + if (modulekind !== 5 /* ES6 */ && node.kind === 213 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } emitEnd(node); - if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) { + if (node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */) { emitTrailingComments(node); } } @@ -31897,7 +32840,7 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 172 /* ArrowFunction */; + var isArrowFunction = node.kind === 174 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* CaptureArguments */) !== 0; var args; // An async function is emit as an outer function that calls an inner @@ -32018,7 +32961,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 190 /* Block */) { + if (node.body.kind === 192 /* Block */) { emitBlockFunctionBody(node, node.body); } else { @@ -32073,10 +33016,10 @@ var ts; write(" "); // Unwrap all type assertions. var current = body; - while (current.kind === 169 /* TypeAssertionExpression */) { + while (current.kind === 171 /* TypeAssertionExpression */) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 163 /* ObjectLiteralExpression */); + emitParenthesizedIf(body, current.kind === 165 /* ObjectLiteralExpression */); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -32152,11 +33095,11 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 193 /* ExpressionStatement */) { + if (statement && statement.kind === 195 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 166 /* CallExpression */) { + if (expr && expr.kind === 168 /* CallExpression */) { var func = expr.expression; - if (func && func.kind === 93 /* SuperKeyword */) { + if (func && func.kind === 95 /* SuperKeyword */) { return statement; } } @@ -32188,7 +33131,7 @@ var ts; emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 134 /* ComputedPropertyName */) { + else if (memberName.kind === 136 /* ComputedPropertyName */) { emitComputedPropertyName(memberName); } else { @@ -32200,7 +33143,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 139 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + if (member.kind === 141 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { properties.push(member); } } @@ -32240,11 +33183,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 189 /* SemicolonClassElement */) { + if (member.kind === 191 /* SemicolonClassElement */) { writeLine(); write(";"); } - else if (member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) { + else if (member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) { if (!member.body) { return emitCommentsOnNotEmittedNode(member); } @@ -32261,7 +33204,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */) { + else if (member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -32311,22 +33254,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) && !member.body) { + if ((member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) && !member.body) { emitCommentsOnNotEmittedNode(member); } - else if (member.kind === 141 /* MethodDeclaration */ || - member.kind === 143 /* GetAccessor */ || - member.kind === 144 /* SetAccessor */) { + else if (member.kind === 143 /* MethodDeclaration */ || + member.kind === 145 /* GetAccessor */ || + member.kind === 146 /* SetAccessor */) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128 /* Static */) { write("static "); } - if (member.kind === 143 /* GetAccessor */) { + if (member.kind === 145 /* GetAccessor */) { write("get "); } - else if (member.kind === 144 /* SetAccessor */) { + else if (member.kind === 146 /* SetAccessor */) { write("set "); } if (member.asteriskToken) { @@ -32337,7 +33280,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 189 /* SemicolonClassElement */) { + else if (member.kind === 191 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -32362,11 +33305,11 @@ var ts; var hasInstancePropertyWithInitializer = false; // Emit the constructor overload pinned comments ts.forEach(node.members, function (member) { - if (member.kind === 142 /* Constructor */ && !member.body) { + if (member.kind === 144 /* Constructor */ && !member.body) { emitCommentsOnNotEmittedNode(member); } // Check if there is any non-static property assignment - if (member.kind === 139 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + if (member.kind === 141 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -32476,10 +33419,13 @@ var ts; else { emitClassLikeDeclarationForES6AndHigher(node); } + if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 212 /* ClassDeclaration */) { + if (node.kind === 214 /* ClassDeclaration */) { if (thisNodeIsDecorated) { // To preserve the correct runtime semantics when decorators are applied to the class, // the emit needs to follow one of the following rules: @@ -32493,7 +33439,6 @@ var ts; // // let C = class { // }; - // Object.defineProperty(C, "name", { value: "C", configurable: true }); // C = __decorate([dec], C); // // * For an exported class declaration: @@ -32505,7 +33450,6 @@ var ts; // // export let C = class { // }; - // Object.defineProperty(C, "name", { value: "C", configurable: true }); // C = __decorate([dec], C); // // * For a default export of a class declaration with a name: @@ -32517,7 +33461,6 @@ var ts; // // let C = class { // } - // Object.defineProperty(C, "name", { value: "C", configurable: true }); // C = __decorate([dec], C); // export default C; // @@ -32559,7 +33502,7 @@ var ts; // This keeps the expression as an expression, while ensuring that the static parts // of it have been initialized by the time it is used. var staticProperties = getInitializedProperties(node, /*static:*/ true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184 /* ClassExpression */; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 186 /* ClassExpression */; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0 /* Auto */); @@ -32569,8 +33512,10 @@ var ts; write(" = "); } write("class"); - // check if this is an "export default class" as it may not have a name. Do not emit the name if the class is decorated. - if ((node.name || !(node.flags & 1024 /* Default */)) && !thisNodeIsDecorated) { + // emit name if + // - node has a name + // - this is default export with static initializers + if ((node.name || (node.flags & 1024 /* Default */ && staticProperties.length > 0)) && !thisNodeIsDecorated) { write(" "); emitDeclarationName(node); } @@ -32643,7 +33588,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 212 /* ClassDeclaration */) { + if (node.kind === 214 /* ClassDeclaration */) { // source file level classes in system modules are hoisted so 'var's for them are already defined if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); @@ -32702,16 +33647,13 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 212 /* ClassDeclaration */) { + if (node.kind === 214 /* ClassDeclaration */) { write(";"); } emitEnd(node); - if (node.kind === 212 /* ClassDeclaration */) { + if (node.kind === 214 /* ClassDeclaration */) { emitExportMemberAssignment(node); } - if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } } function emitClassMemberPrefix(node, member) { emitDeclarationName(node); @@ -32798,7 +33740,7 @@ var ts; else { decorators = member.decorators; // we only decorate the parameters here if this is a method - if (member.kind === 141 /* MethodDeclaration */) { + if (member.kind === 143 /* MethodDeclaration */) { functionLikeMember = member; } } @@ -32812,21 +33754,19 @@ var ts; // // The emit for a method is: // - // Object.defineProperty(C.prototype, "method", - // __decorate([ - // dec, - // __param(0, dec2), - // __metadata("design:type", Function), - // __metadata("design:paramtypes", [Object]), - // __metadata("design:returntype", void 0) - // ], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); + // __decorate([ + // dec, + // __param(0, dec2), + // __metadata("design:type", Function), + // __metadata("design:paramtypes", [Object]), + // __metadata("design:returntype", void 0) + // ], C.prototype, "method", undefined); // // The emit for an accessor is: // - // Object.defineProperty(C.prototype, "accessor", - // __decorate([ - // dec - // ], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor"))); + // __decorate([ + // dec + // ], C.prototype, "accessor", undefined); // // The emit for a property is: // @@ -32836,17 +33776,6 @@ var ts; // writeLine(); emitStart(member); - if (member.kind !== 139 /* PropertyDeclaration */) { - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(","); - increaseIndent(); - writeLine(); - } write("__decorate(["); increaseIndent(); writeLine(); @@ -32866,15 +33795,17 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 139 /* PropertyDeclaration */) { - write(", Object.getOwnPropertyDescriptor("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write("))"); - decreaseIndent(); + if (languageVersion > 0 /* ES3 */) { + if (member.kind !== 141 /* PropertyDeclaration */) { + // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly. + // We have this extra argument here so that we can inject an explicit property descriptor at a later date. + write(", null"); + } + else { + // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it + // should not invoke `Object.getOwnPropertyDescriptor`. + write(", void 0"); + } } write(");"); emitEnd(member); @@ -32908,10 +33839,10 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 139 /* PropertyDeclaration */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 141 /* PropertyDeclaration */: return true; } return false; @@ -32921,7 +33852,7 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 141 /* MethodDeclaration */: + case 143 /* MethodDeclaration */: return true; } return false; @@ -32931,9 +33862,9 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 212 /* ClassDeclaration */: - case 141 /* MethodDeclaration */: - case 144 /* SetAccessor */: + case 214 /* ClassDeclaration */: + case 143 /* MethodDeclaration */: + case 146 /* SetAccessor */: return true; } return false; @@ -32951,19 +33882,19 @@ var ts; // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: write("Function"); return; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: emitSerializedTypeNode(node.type); return; - case 136 /* Parameter */: + case 138 /* Parameter */: emitSerializedTypeNode(node.type); return; - case 143 /* GetAccessor */: + case 145 /* GetAccessor */: emitSerializedTypeNode(node.type); return; - case 144 /* SetAccessor */: + case 146 /* SetAccessor */: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -32976,42 +33907,42 @@ var ts; function emitSerializedTypeNode(node) { if (node) { switch (node.kind) { - case 101 /* VoidKeyword */: + case 103 /* VoidKeyword */: write("void 0"); return; - case 158 /* ParenthesizedType */: + case 160 /* ParenthesizedType */: emitSerializedTypeNode(node.type); return; - case 150 /* FunctionType */: - case 151 /* ConstructorType */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: write("Function"); return; - case 154 /* ArrayType */: - case 155 /* TupleType */: + case 156 /* ArrayType */: + case 157 /* TupleType */: write("Array"); return; - case 148 /* TypePredicate */: - case 118 /* BooleanKeyword */: + case 150 /* TypePredicate */: + case 120 /* BooleanKeyword */: write("Boolean"); return; - case 128 /* StringKeyword */: + case 130 /* StringKeyword */: case 9 /* StringLiteral */: write("String"); return; - case 126 /* NumberKeyword */: + case 128 /* NumberKeyword */: write("Number"); return; - case 129 /* SymbolKeyword */: + case 131 /* SymbolKeyword */: write("Symbol"); return; - case 149 /* TypeReference */: + case 151 /* TypeReference */: emitSerializedTypeReferenceNode(node); return; - case 152 /* TypeQuery */: - case 153 /* TypeLiteral */: - case 156 /* UnionType */: - case 157 /* IntersectionType */: - case 115 /* AnyKeyword */: + case 154 /* TypeQuery */: + case 155 /* TypeLiteral */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: + case 117 /* AnyKeyword */: break; default: ts.Debug.fail("Cannot serialize unexpected type node."); @@ -33085,7 +34016,7 @@ var ts; // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { var valueDeclaration; - if (node.kind === 212 /* ClassDeclaration */) { + if (node.kind === 214 /* ClassDeclaration */) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -33101,10 +34032,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 154 /* ArrayType */) { + if (parameterType.kind === 156 /* ArrayType */) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 149 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 151 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -33222,8 +34153,8 @@ var ts; emitEnd(node); write(";"); } - if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile) { - if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) { + if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { + if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { // write the call to exporter for enum writeLine(); write(exportFunctionForFile + "(\""); @@ -33264,7 +34195,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 218 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -33300,7 +34231,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 217 /* ModuleBlock */) { + if (node.body.kind === 219 /* ModuleBlock */) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -33333,8 +34264,8 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 67 /* Identifier */ && node.parent === currentSourceFile) { - if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 69 /* Identifier */ && node.parent === currentSourceFile) { + if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -33374,16 +34305,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 219 /* ImportEqualsDeclaration */) { + if (node.kind === 221 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 224 /* NamespaceImport */) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 220 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 222 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -33392,7 +34323,7 @@ var ts; ts.forEachChild(node, emitExportImportAssignments); } function emitImportDeclaration(node) { - if (languageVersion < 2 /* ES6 */) { + if (modulekind !== 5 /* ES6 */) { return emitExternalImportDeclaration(node); } // ES6 import @@ -33411,7 +34342,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 224 /* NamespaceImport */) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -33437,9 +34368,9 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 219 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var isExportedImport = node.kind === 221 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (compilerOptions.module !== 2 /* AMD */) { + if (modulekind !== 2 /* AMD */) { emitLeadingComments(node); emitStart(node); if (namespaceDeclaration && !isDefaultImport(node)) { @@ -33456,7 +34387,7 @@ var ts; // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - var isNakedImport = 220 /* ImportDeclaration */ && !node.importClause; + var isNakedImport = 222 /* ImportDeclaration */ && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -33541,14 +34472,14 @@ var ts; } } function emitExportDeclaration(node) { - ts.Debug.assert(compilerOptions.module !== 4 /* System */); - if (languageVersion < 2 /* ES6 */) { + ts.Debug.assert(modulekind !== 4 /* System */); + if (modulekind !== 5 /* ES6 */) { if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { emitStart(node); var generatedName = getGeneratedNameForNode(node); if (node.exportClause) { // export { x, y, ... } from "foo" - if (compilerOptions.module !== 2 /* AMD */) { + if (modulekind !== 2 /* AMD */) { write("var "); write(generatedName); write(" = "); @@ -33576,7 +34507,7 @@ var ts; // export * from "foo" writeLine(); write("__export("); - if (compilerOptions.module !== 2 /* AMD */) { + if (modulekind !== 2 /* AMD */) { emitRequire(ts.getExternalModuleName(node)); } else { @@ -33608,7 +34539,7 @@ var ts; } } function emitExportOrImportSpecifierList(specifiers, shouldEmit) { - ts.Debug.assert(languageVersion >= 2 /* ES6 */); + ts.Debug.assert(modulekind === 5 /* ES6 */); var needsComma = false; for (var _a = 0; _a < specifiers.length; _a++) { var specifier = specifiers[_a]; @@ -33627,14 +34558,14 @@ var ts; } function emitExportAssignment(node) { if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { - if (languageVersion >= 2 /* ES6 */) { + if (modulekind === 5 /* ES6 */) { writeLine(); emitStart(node); write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 211 /* FunctionDeclaration */ && - expression.kind !== 212 /* ClassDeclaration */) { + if (expression.kind !== 213 /* FunctionDeclaration */ && + expression.kind !== 214 /* ClassDeclaration */) { write(";"); } emitEnd(node); @@ -33642,7 +34573,7 @@ var ts; else { writeLine(); emitStart(node); - if (compilerOptions.module === 4 /* System */) { + if (modulekind === 4 /* System */) { write(exportFunctionForFile + "(\"default\","); emit(node.expression); write(")"); @@ -33671,7 +34602,7 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, /*checkChildren*/ true)) { // import "mod" @@ -33681,13 +34612,13 @@ var ts; externalImports.push(node); } break; - case 219 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 230 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + case 221 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 232 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { // import x = require("mod") where x is referenced externalImports.push(node); } break; - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -33703,12 +34634,12 @@ var ts; // export { x, y } for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_24 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier); + var name_25 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_25] || (exportSpecifiers[name_25] = [])).push(specifier); } } break; - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -33734,10 +34665,10 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - if (node.kind === 220 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 222 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 226 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 228 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } @@ -33757,8 +34688,8 @@ var ts; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; // do not create variable declaration for exports and imports that lack import clause - var skipNode = importNode.kind === 226 /* ExportDeclaration */ || - (importNode.kind === 220 /* ImportDeclaration */ && !importNode.importClause); + var skipNode = importNode.kind === 228 /* ExportDeclaration */ || + (importNode.kind === 222 /* ImportDeclaration */ && !importNode.importClause); if (skipNode) { continue; } @@ -33791,7 +34722,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 226 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 228 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -33823,7 +34754,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 226 /* ExportDeclaration */) { + if (externalImport.kind !== 228 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -33871,7 +34802,7 @@ var ts; function writeExportedName(node) { // do not record default exports // they are local to module and never overwritten (explicitly skipped) by star export - if (node.kind !== 67 /* Identifier */ && node.flags & 1024 /* Default */) { + if (node.kind !== 69 /* Identifier */ && node.flags & 1024 /* Default */) { return; } if (started) { @@ -33882,7 +34813,7 @@ var ts; } writeLine(); write("'"); - if (node.kind === 67 /* Identifier */) { + if (node.kind === 69 /* Identifier */) { emitNodeWithCommentsAndWithoutSourcemap(node); } else { @@ -33911,12 +34842,12 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_25 = local.kind === 67 /* Identifier */ + var name_26 = local.kind === 69 /* Identifier */ ? local : local.name; - if (name_25) { + if (name_26) { // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables - var text = ts.unescapeIdentifier(name_25.text); + var text = ts.unescapeIdentifier(name_26.text); if (ts.hasProperty(seen, text)) { continue; } @@ -33927,13 +34858,13 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 212 /* ClassDeclaration */ || local.kind === 216 /* ModuleDeclaration */ || local.kind === 215 /* EnumDeclaration */) { + if (local.kind === 214 /* ClassDeclaration */ || local.kind === 218 /* ModuleDeclaration */ || local.kind === 217 /* EnumDeclaration */) { emitDeclarationName(local); } else { emit(local); } - var flags = ts.getCombinedNodeFlags(local.kind === 67 /* Identifier */ ? local.parent : local); + var flags = ts.getCombinedNodeFlags(local.kind === 69 /* Identifier */ ? local.parent : local); if (flags & 1 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -33961,21 +34892,21 @@ var ts; if (node.flags & 2 /* Ambient */) { return; } - if (node.kind === 211 /* FunctionDeclaration */) { + if (node.kind === 213 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 212 /* ClassDeclaration */) { + if (node.kind === 214 /* ClassDeclaration */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 215 /* EnumDeclaration */) { + if (node.kind === 217 /* EnumDeclaration */) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -33984,7 +34915,7 @@ var ts; } return; } - if (node.kind === 216 /* ModuleDeclaration */) { + if (node.kind === 218 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -33993,17 +34924,17 @@ var ts; } return; } - if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) { + if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) { if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { - var name_26 = node.name; - if (name_26.kind === 67 /* Identifier */) { + var name_27 = node.name; + if (name_27.kind === 69 /* Identifier */) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_26); + hoistedVars.push(name_27); } else { - ts.forEachChild(name_26, visit); + ts.forEachChild(name_27, visit); } } return; @@ -34034,10 +34965,10 @@ var ts; // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 246 /* SourceFile */; + ts.getEnclosingBlockScopeContainer(node).kind === 248 /* SourceFile */; } function isCurrentFileSystemExternalModule() { - return compilerOptions.module === 4 /* System */ && ts.isExternalModule(currentSourceFile); + return modulekind === 4 /* System */ && ts.isExternalModule(currentSourceFile); } function emitSystemModuleBody(node, dependencyGroups, startIndex) { // shape of the body in system modules: @@ -34109,21 +35040,21 @@ var ts; var entry = group[_a]; var importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // fall-through - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== ""); writeLine(); // save import into the local write(importVariableName + " = " + parameterName + ";"); writeLine(); break; - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== ""); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -34180,10 +35111,10 @@ var ts; // - import declarations are not emitted since they are already handled in setters // - export declarations with module specifiers are not emitted since they were already written in setters // - export declarations without module specifiers are emitted preserving the order - case 211 /* FunctionDeclaration */: - case 220 /* ImportDeclaration */: + case 213 /* FunctionDeclaration */: + case 222 /* ImportDeclaration */: continue; - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: if (!statement.moduleSpecifier) { for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { var element = _b[_a]; @@ -34192,7 +35123,7 @@ var ts; } } continue; - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { // - import equals declarations that import external modules are not emitted continue; @@ -34207,7 +35138,7 @@ var ts; writeLine(); write("}"); // execute } - function emitSystemModule(node, startIndex) { + function emitSystemModule(node) { collectExternalModuleInfo(node); // System modules has the following shape // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) @@ -34248,6 +35179,7 @@ var ts; write("], function(" + exportFunctionForFile + ") {"); writeLine(); increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitSystemModuleBody(node, dependencyGroups, startIndex); @@ -34255,18 +35187,7 @@ var ts; writeLine(); write("});"); } - function emitAMDDependencies(node, includeNonAmdDependencies) { - // An AMD define function has the following shape: - // define(id?, dependencies?, factory); - // - // This has the shape of - // define(name, ["module1", "module2"], function (module1Alias) { - // The location of the alias in the parameter list in the factory function needs to - // match the position of the module name in the dependency list. - // - // To ensure this is true in cases of modules with no aliases, e.g.: - // `import "module"` or `` - // we need to add modules without alias names to the end of the dependencies list + function getAMDDependencyNames(node, includeNonAmdDependencies) { // names of modules with corresponding parameter in the factory function var aliasedModuleNames = []; // names of modules with no corresponding parameters in factory function @@ -34299,6 +35220,27 @@ var ts; unaliasedModuleNames.push(externalModuleName); } } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + function emitAMDDependencies(node, includeNonAmdDependencies) { + // An AMD define function has the following shape: + // define(id?, dependencies?, factory); + // + // This has the shape of + // define(name, ["module1", "module2"], function (module1Alias) { + // The location of the alias in the parameter list in the factory function needs to + // match the position of the module name in the dependency list. + // + // To ensure this is true in cases of modules with no aliases, e.g.: + // `import "module"` or `` + // we need to add modules without alias names to the end of the dependencies list + var dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); + emitAMDDependencyList(dependencyNames); + write(", "); + emitAMDFactoryHeader(dependencyNames); + } + function emitAMDDependencyList(_a) { + var aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames; write("[\"require\", \"exports\""); if (aliasedModuleNames.length) { write(", "); @@ -34308,13 +35250,18 @@ var ts; write(", "); write(unaliasedModuleNames.join(", ")); } - write("], function (require, exports"); + write("]"); + } + function emitAMDFactoryHeader(_a) { + var importAliasNames = _a.importAliasNames; + write("function (require, exports"); if (importAliasNames.length) { write(", "); write(importAliasNames.join(", ")); } + write(") {"); } - function emitAMDModule(node, startIndex) { + function emitAMDModule(node) { emitEmitHelpers(node); collectExternalModuleInfo(node); writeLine(); @@ -34323,8 +35270,8 @@ var ts; write("\"" + node.moduleName + "\", "); } emitAMDDependencies(node, /*includeNonAmdDependencies*/ true); - write(") {"); increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -34334,7 +35281,8 @@ var ts; writeLine(); write("});"); } - function emitCommonJSModule(node, startIndex) { + function emitCommonJSModule(node) { + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); @@ -34343,14 +35291,18 @@ var ts; emitTempDeclarations(/*newLine*/ true); emitExportEquals(/*emitAsReturn*/ false); } - function emitUMDModule(node, startIndex) { + function emitUMDModule(node) { emitEmitHelpers(node); collectExternalModuleInfo(node); + var dependencyNames = getAMDDependencyNames(node, /*includeNonAmdDependencies*/ false); // Module is detected first to support Browserify users that load into a browser with an AMD loader - writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); - emitAMDDependencies(node, false); - write(") {"); + writeLines("(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define("); + emitAMDDependencyList(dependencyNames); + write(", factory);"); + writeLines(" }\n})("); + emitAMDFactoryHeader(dependencyNames); increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -34360,11 +35312,12 @@ var ts; writeLine(); write("});"); } - function emitES6Module(node, startIndex) { + function emitES6Module(node) { externalImports = undefined; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -34407,7 +35360,7 @@ var ts; if (ts.isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + "\" + ' ' + \"" : "") + part; + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); } firstNonWhitespace = -1; } @@ -34420,7 +35373,7 @@ var ts; } if (firstNonWhitespace !== -1) { var part = text.substr(firstNonWhitespace); - result = (result ? result + "\" + ' ' + \"" : "") + part; + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); } if (result) { // Replace entities like   @@ -34534,26 +35487,13 @@ var ts; writeLine(); emitShebang(); emitDetachedComments(node); - // emit prologue directives prior to __extends - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - if (languageVersion >= 2 /* ES6 */) { - emitES6Module(node, startIndex); - } - else if (compilerOptions.module === 2 /* AMD */) { - emitAMDModule(node, startIndex); - } - else if (compilerOptions.module === 4 /* System */) { - emitSystemModule(node, startIndex); - } - else if (compilerOptions.module === 3 /* UMD */) { - emitUMDModule(node, startIndex); - } - else { - emitCommonJSModule(node, startIndex); - } + var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1 /* CommonJS */]; + emitModule(node); } else { + // emit prologue directives prior to __extends + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); externalImports = undefined; exportSpecifiers = undefined; exportEquals = undefined; @@ -34596,38 +35536,38 @@ var ts; switch (node.kind) { // All of these entities are emitted in a specialized fashion. As such, we allow // the specialized methods for each to handle the comments on the nodes. - case 213 /* InterfaceDeclaration */: - case 211 /* FunctionDeclaration */: - case 220 /* ImportDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 225 /* ExportAssignment */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 227 /* ExportAssignment */: return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well. return shouldEmitModuleDeclaration(node); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: // Only emit the leading/trailing comments for an enum if we're actually // emitting the module as well. return shouldEmitEnumDeclaration(node); } - // If the node is emitted in specialized fashion, dont emit comments as this node will handle + // If the node is emitted in specialized fashion, dont emit comments as this node will handle // emitting comments when emitting itself ts.Debug.assert(!isSpecializedCommentHandling(node)); // If this is the expression body of an arrow function that we're down-leveling, // then we don't want to emit comments when we emit the body. It will have already // been taken care of when we emitted the 'return' statement for the function // expression body. - if (node.kind !== 190 /* Block */ && + if (node.kind !== 192 /* Block */ && node.parent && - node.parent.kind === 172 /* ArrowFunction */ && + node.parent.kind === 174 /* ArrowFunction */ && node.parent.body === node && compilerOptions.target <= 1 /* ES5 */) { return false; @@ -34638,25 +35578,25 @@ var ts; function emitJavaScriptWorker(node) { // Check if the node can be emitted regardless of the ScriptTarget switch (node.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: return emitIdentifier(node); - case 136 /* Parameter */: + case 138 /* Parameter */: return emitParameter(node); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return emitMethod(node); - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return emitAccessor(node); - case 95 /* ThisKeyword */: + case 97 /* ThisKeyword */: return emitThis(node); - case 93 /* SuperKeyword */: + case 95 /* SuperKeyword */: return emitSuper(node); - case 91 /* NullKeyword */: + case 93 /* NullKeyword */: return write("null"); - case 97 /* TrueKeyword */: + case 99 /* TrueKeyword */: return write("true"); - case 82 /* FalseKeyword */: + case 84 /* FalseKeyword */: return write("false"); case 8 /* NumericLiteral */: case 9 /* StringLiteral */: @@ -34666,142 +35606,142 @@ var ts; case 13 /* TemplateMiddle */: case 14 /* TemplateTail */: return emitLiteral(node); - case 181 /* TemplateExpression */: + case 183 /* TemplateExpression */: return emitTemplateExpression(node); - case 188 /* TemplateSpan */: + case 190 /* TemplateSpan */: return emitTemplateSpan(node); - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: return emitJsxElement(node); - case 234 /* JsxText */: + case 236 /* JsxText */: return emitJsxText(node); - case 238 /* JsxExpression */: + case 240 /* JsxExpression */: return emitJsxExpression(node); - case 133 /* QualifiedName */: + case 135 /* QualifiedName */: return emitQualifiedName(node); - case 159 /* ObjectBindingPattern */: + case 161 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 160 /* ArrayBindingPattern */: + case 162 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 161 /* BindingElement */: + case 163 /* BindingElement */: return emitBindingElement(node); - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 243 /* PropertyAssignment */: + case 245 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 244 /* ShorthandPropertyAssignment */: + case 246 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: return emitComputedPropertyName(node); - case 164 /* PropertyAccessExpression */: + case 166 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 165 /* ElementAccessExpression */: + case 167 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 166 /* CallExpression */: + case 168 /* CallExpression */: return emitCallExpression(node); - case 167 /* NewExpression */: + case 169 /* NewExpression */: return emitNewExpression(node); - case 168 /* TaggedTemplateExpression */: + case 170 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 169 /* TypeAssertionExpression */: + case 171 /* TypeAssertionExpression */: return emit(node.expression); - case 187 /* AsExpression */: + case 189 /* AsExpression */: return emit(node.expression); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return emitParenExpression(node); - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 173 /* DeleteExpression */: + case 175 /* DeleteExpression */: return emitDeleteExpression(node); - case 174 /* TypeOfExpression */: + case 176 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 175 /* VoidExpression */: + case 177 /* VoidExpression */: return emitVoidExpression(node); - case 176 /* AwaitExpression */: + case 178 /* AwaitExpression */: return emitAwaitExpression(node); - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 178 /* PostfixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return emitBinaryExpression(node); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return emitConditionalExpression(node); - case 183 /* SpreadElementExpression */: + case 185 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 182 /* YieldExpression */: + case 184 /* YieldExpression */: return emitYieldExpression(node); - case 185 /* OmittedExpression */: + case 187 /* OmittedExpression */: return; - case 190 /* Block */: - case 217 /* ModuleBlock */: + case 192 /* Block */: + case 219 /* ModuleBlock */: return emitBlock(node); - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: return emitVariableStatement(node); - case 192 /* EmptyStatement */: + case 194 /* EmptyStatement */: return write(";"); - case 193 /* ExpressionStatement */: + case 195 /* ExpressionStatement */: return emitExpressionStatement(node); - case 194 /* IfStatement */: + case 196 /* IfStatement */: return emitIfStatement(node); - case 195 /* DoStatement */: + case 197 /* DoStatement */: return emitDoStatement(node); - case 196 /* WhileStatement */: + case 198 /* WhileStatement */: return emitWhileStatement(node); - case 197 /* ForStatement */: + case 199 /* ForStatement */: return emitForStatement(node); - case 199 /* ForOfStatement */: - case 198 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 200 /* ForInStatement */: return emitForInOrForOfStatement(node); - case 200 /* ContinueStatement */: - case 201 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 202 /* ReturnStatement */: + case 204 /* ReturnStatement */: return emitReturnStatement(node); - case 203 /* WithStatement */: + case 205 /* WithStatement */: return emitWithStatement(node); - case 204 /* SwitchStatement */: + case 206 /* SwitchStatement */: return emitSwitchStatement(node); - case 239 /* CaseClause */: - case 240 /* DefaultClause */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: return emitLabelledStatement(node); - case 206 /* ThrowStatement */: + case 208 /* ThrowStatement */: return emitThrowStatement(node); - case 207 /* TryStatement */: + case 209 /* TryStatement */: return emitTryStatement(node); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return emitCatchClause(node); - case 208 /* DebuggerStatement */: + case 210 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 209 /* VariableDeclaration */: + case 211 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 184 /* ClassExpression */: + case 186 /* ClassExpression */: return emitClassExpression(node); - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: return emitClassDeclaration(node); - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 245 /* EnumMember */: + case 247 /* EnumMember */: return emitEnumMember(node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: return emitImportDeclaration(node); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return emitExportDeclaration(node); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return emitExportAssignment(node); - case 246 /* SourceFile */: + case 248 /* SourceFile */: return emitSourceFileNode(node); } } @@ -34844,7 +35784,7 @@ var ts; function getLeadingCommentsToEmit(node) { // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 246 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 248 /* SourceFile */ || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { // get comments without detached comments return getLeadingCommentsWithoutDetachedComments(); @@ -34859,7 +35799,7 @@ var ts; function getTrailingCommentsToEmit(node) { // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 246 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 248 /* SourceFile */ || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -34997,6 +35937,7 @@ var ts; write(shebang); } } + var _a; } function emitFile(jsFilePath, sourceFile) { emitJavaScript(jsFilePath, sourceFile); @@ -35006,261 +35947,6 @@ var ts; } } ts.emitFiles = emitFiles; - var entities = { - "quot": 0x0022, - "amp": 0x0026, - "apos": 0x0027, - "lt": 0x003C, - "gt": 0x003E, - "nbsp": 0x00A0, - "iexcl": 0x00A1, - "cent": 0x00A2, - "pound": 0x00A3, - "curren": 0x00A4, - "yen": 0x00A5, - "brvbar": 0x00A6, - "sect": 0x00A7, - "uml": 0x00A8, - "copy": 0x00A9, - "ordf": 0x00AA, - "laquo": 0x00AB, - "not": 0x00AC, - "shy": 0x00AD, - "reg": 0x00AE, - "macr": 0x00AF, - "deg": 0x00B0, - "plusmn": 0x00B1, - "sup2": 0x00B2, - "sup3": 0x00B3, - "acute": 0x00B4, - "micro": 0x00B5, - "para": 0x00B6, - "middot": 0x00B7, - "cedil": 0x00B8, - "sup1": 0x00B9, - "ordm": 0x00BA, - "raquo": 0x00BB, - "frac14": 0x00BC, - "frac12": 0x00BD, - "frac34": 0x00BE, - "iquest": 0x00BF, - "Agrave": 0x00C0, - "Aacute": 0x00C1, - "Acirc": 0x00C2, - "Atilde": 0x00C3, - "Auml": 0x00C4, - "Aring": 0x00C5, - "AElig": 0x00C6, - "Ccedil": 0x00C7, - "Egrave": 0x00C8, - "Eacute": 0x00C9, - "Ecirc": 0x00CA, - "Euml": 0x00CB, - "Igrave": 0x00CC, - "Iacute": 0x00CD, - "Icirc": 0x00CE, - "Iuml": 0x00CF, - "ETH": 0x00D0, - "Ntilde": 0x00D1, - "Ograve": 0x00D2, - "Oacute": 0x00D3, - "Ocirc": 0x00D4, - "Otilde": 0x00D5, - "Ouml": 0x00D6, - "times": 0x00D7, - "Oslash": 0x00D8, - "Ugrave": 0x00D9, - "Uacute": 0x00DA, - "Ucirc": 0x00DB, - "Uuml": 0x00DC, - "Yacute": 0x00DD, - "THORN": 0x00DE, - "szlig": 0x00DF, - "agrave": 0x00E0, - "aacute": 0x00E1, - "acirc": 0x00E2, - "atilde": 0x00E3, - "auml": 0x00E4, - "aring": 0x00E5, - "aelig": 0x00E6, - "ccedil": 0x00E7, - "egrave": 0x00E8, - "eacute": 0x00E9, - "ecirc": 0x00EA, - "euml": 0x00EB, - "igrave": 0x00EC, - "iacute": 0x00ED, - "icirc": 0x00EE, - "iuml": 0x00EF, - "eth": 0x00F0, - "ntilde": 0x00F1, - "ograve": 0x00F2, - "oacute": 0x00F3, - "ocirc": 0x00F4, - "otilde": 0x00F5, - "ouml": 0x00F6, - "divide": 0x00F7, - "oslash": 0x00F8, - "ugrave": 0x00F9, - "uacute": 0x00FA, - "ucirc": 0x00FB, - "uuml": 0x00FC, - "yacute": 0x00FD, - "thorn": 0x00FE, - "yuml": 0x00FF, - "OElig": 0x0152, - "oelig": 0x0153, - "Scaron": 0x0160, - "scaron": 0x0161, - "Yuml": 0x0178, - "fnof": 0x0192, - "circ": 0x02C6, - "tilde": 0x02DC, - "Alpha": 0x0391, - "Beta": 0x0392, - "Gamma": 0x0393, - "Delta": 0x0394, - "Epsilon": 0x0395, - "Zeta": 0x0396, - "Eta": 0x0397, - "Theta": 0x0398, - "Iota": 0x0399, - "Kappa": 0x039A, - "Lambda": 0x039B, - "Mu": 0x039C, - "Nu": 0x039D, - "Xi": 0x039E, - "Omicron": 0x039F, - "Pi": 0x03A0, - "Rho": 0x03A1, - "Sigma": 0x03A3, - "Tau": 0x03A4, - "Upsilon": 0x03A5, - "Phi": 0x03A6, - "Chi": 0x03A7, - "Psi": 0x03A8, - "Omega": 0x03A9, - "alpha": 0x03B1, - "beta": 0x03B2, - "gamma": 0x03B3, - "delta": 0x03B4, - "epsilon": 0x03B5, - "zeta": 0x03B6, - "eta": 0x03B7, - "theta": 0x03B8, - "iota": 0x03B9, - "kappa": 0x03BA, - "lambda": 0x03BB, - "mu": 0x03BC, - "nu": 0x03BD, - "xi": 0x03BE, - "omicron": 0x03BF, - "pi": 0x03C0, - "rho": 0x03C1, - "sigmaf": 0x03C2, - "sigma": 0x03C3, - "tau": 0x03C4, - "upsilon": 0x03C5, - "phi": 0x03C6, - "chi": 0x03C7, - "psi": 0x03C8, - "omega": 0x03C9, - "thetasym": 0x03D1, - "upsih": 0x03D2, - "piv": 0x03D6, - "ensp": 0x2002, - "emsp": 0x2003, - "thinsp": 0x2009, - "zwnj": 0x200C, - "zwj": 0x200D, - "lrm": 0x200E, - "rlm": 0x200F, - "ndash": 0x2013, - "mdash": 0x2014, - "lsquo": 0x2018, - "rsquo": 0x2019, - "sbquo": 0x201A, - "ldquo": 0x201C, - "rdquo": 0x201D, - "bdquo": 0x201E, - "dagger": 0x2020, - "Dagger": 0x2021, - "bull": 0x2022, - "hellip": 0x2026, - "permil": 0x2030, - "prime": 0x2032, - "Prime": 0x2033, - "lsaquo": 0x2039, - "rsaquo": 0x203A, - "oline": 0x203E, - "frasl": 0x2044, - "euro": 0x20AC, - "image": 0x2111, - "weierp": 0x2118, - "real": 0x211C, - "trade": 0x2122, - "alefsym": 0x2135, - "larr": 0x2190, - "uarr": 0x2191, - "rarr": 0x2192, - "darr": 0x2193, - "harr": 0x2194, - "crarr": 0x21B5, - "lArr": 0x21D0, - "uArr": 0x21D1, - "rArr": 0x21D2, - "dArr": 0x21D3, - "hArr": 0x21D4, - "forall": 0x2200, - "part": 0x2202, - "exist": 0x2203, - "empty": 0x2205, - "nabla": 0x2207, - "isin": 0x2208, - "notin": 0x2209, - "ni": 0x220B, - "prod": 0x220F, - "sum": 0x2211, - "minus": 0x2212, - "lowast": 0x2217, - "radic": 0x221A, - "prop": 0x221D, - "infin": 0x221E, - "ang": 0x2220, - "and": 0x2227, - "or": 0x2228, - "cap": 0x2229, - "cup": 0x222A, - "int": 0x222B, - "there4": 0x2234, - "sim": 0x223C, - "cong": 0x2245, - "asymp": 0x2248, - "ne": 0x2260, - "equiv": 0x2261, - "le": 0x2264, - "ge": 0x2265, - "sub": 0x2282, - "sup": 0x2283, - "nsub": 0x2284, - "sube": 0x2286, - "supe": 0x2287, - "oplus": 0x2295, - "otimes": 0x2297, - "perp": 0x22A5, - "sdot": 0x22C5, - "lceil": 0x2308, - "rceil": 0x2309, - "lfloor": 0x230A, - "rfloor": 0x230B, - "lang": 0x2329, - "rang": 0x232A, - "loz": 0x25CA, - "spades": 0x2660, - "clubs": 0x2663, - "hearts": 0x2665, - "diams": 0x2666 - }; })(ts || (ts = {})); /// /// @@ -35311,11 +35997,11 @@ var ts; if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { var failedLookupLocations = []; var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + var resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (resolvedFileName) { return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; } - resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); return resolvedFileName ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; @@ -35325,13 +36011,8 @@ var ts; } } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { - if (loadOnlyDts) { - return tryLoad(".d.ts"); - } - else { - return ts.forEach(ts.supportedExtensions, tryLoad); - } + function loadNodeModuleFromFile(candidate, failedLookupLocation, host) { + return ts.forEach(ts.supportedJsExtensions, tryLoad); function tryLoad(ext) { var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; if (host.fileExists(fileName)) { @@ -35343,7 +36024,7 @@ var ts; } } } - function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + function loadNodeModuleFromDirectory(candidate, failedLookupLocation, host) { var packageJsonPath = ts.combinePaths(candidate, "package.json"); if (host.fileExists(packageJsonPath)) { var jsonContent; @@ -35356,7 +36037,7 @@ var ts; jsonContent = { typings: undefined }; } if (jsonContent.typings) { - var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); if (result) { return result; } @@ -35366,7 +36047,7 @@ var ts; // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results failedLookupLocation.push(packageJsonPath); } - return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), failedLookupLocation, host); } function loadModuleFromNodeModules(moduleName, directory, host) { var failedLookupLocations = []; @@ -35376,11 +36057,11 @@ var ts; if (baseName !== "node_modules") { var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + var result = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; } - result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; } @@ -35399,16 +36080,17 @@ var ts; } function classicNameResolver(moduleName, containingFile, compilerOptions, host) { // module names that contain '!' are used to reference resources and are not resolved to actual files on disk - if (moduleName.indexOf('!') != -1) { + if (moduleName.indexOf("!") != -1) { return { resolvedModule: undefined, failedLookupLocations: [] }; } var searchPath = ts.getDirectoryPath(containingFile); var searchName; var failedLookupLocations = []; var referencedSourceFile; + var extensions = compilerOptions.allowNonTsExtensions ? ts.supportedJsExtensions : ts.supportedExtensions; while (true) { searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + referencedSourceFile = ts.forEach(extensions, function (extension) { if (extension === ".tsx" && !compilerOptions.jsx) { // resolve .tsx files only if jsx support is enabled // 'logical not' handles both undefined and None cases @@ -35746,7 +36428,9 @@ var ts; return emitResult; } function getSourceFile(fileName) { - return filesByName.get(fileName); + // first try to use file name as is to find file + // then try to convert relative file name to absolute and use it to retrieve source file + return filesByName.get(fileName) || filesByName.get(ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory())); } function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { @@ -35842,13 +36526,18 @@ var ts; if (file.imports) { return; } + var isJavaScriptFile = ts.isSourceFileJavaScript(file); var imports; for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var node = _a[_i]; + collect(node, /* allowRelativeModuleNames */ true); + } + file.imports = imports || emptyArray; + function collect(node, allowRelativeModuleNames) { switch (node.kind) { - case 220 /* ImportDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 226 /* ExportDeclaration */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 228 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -35856,9 +36545,24 @@ var ts; if (!moduleNameExpr.text) { break; } - (imports || (imports = [])).push(moduleNameExpr); + if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { + (imports || (imports = [])).push(moduleNameExpr); + } + break; + case 168 /* CallExpression */: + if (isJavaScriptFile && ts.isRequireCall(node)) { + var jsImports = node.arguments; + if (jsImports) { + imports = (imports || []); + for (var i = 0; i < jsImports.length; i++) { + if (jsImports[i].kind === 9 /* StringLiteral */) { + imports.push(jsImports[i]); + } + } + } + } break; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 // An AmbientExternalModuleDeclaration declares an external module. @@ -35866,22 +36570,18 @@ var ts; // The StringLiteral must specify a top - level external module name. // Relative external module names are not permitted ts.forEachChild(node.body, function (node) { - if (ts.isExternalModuleImportEqualsDeclaration(node) && - ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9 /* StringLiteral */) { - var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules - // only through top - level external module names. Relative external module names are not permitted. - if (moduleName) { - (imports || (imports = [])).push(moduleName); - } - } + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules + // only through top - level external module names. Relative external module names are not permitted. + collect(node, /* allowRelativeModuleNames */ false); }); } break; } + if (ts.isSourceFileJavaScript(file)) { + ts.forEachChild(node, function (node) { return collect(node, allowRelativeModuleNames); }); + } } - file.imports = imports || emptyArray; } function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; @@ -35925,52 +36625,52 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - if (filesByName.contains(canonicalName)) { + if (filesByName.contains(fileName)) { // We've already looked for this file, use cached result - return getSourceFileFromCache(fileName, canonicalName, /*useAbsolutePath*/ false); + return getSourceFileFromCache(fileName, /*useAbsolutePath*/ false); } - else { - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); - var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); - if (filesByName.contains(canonicalAbsolutePath)) { - return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, /*useAbsolutePath*/ true); + var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); + if (filesByName.contains(normalizedAbsolutePath)) { + var file_1 = getSourceFileFromCache(normalizedAbsolutePath, /*useAbsolutePath*/ true); + // we don't have resolution for this relative file name but the match was found by absolute file name + // store resolution for relative name as well + filesByName.set(fileName, file_1); + return file_1; + } + // We haven't looked for this file, do so now and cache result + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } - // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }); - filesByName.set(canonicalName, file); - if (file) { - skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - // Set the source file for normalized absolute path - filesByName.set(canonicalAbsolutePath, file); - var basePath = ts.getDirectoryPath(fileName); - if (!options.noResolve) { - processReferencedFiles(file, basePath); - } - // always process imported modules to record module name resolutions - processImportedModules(file, basePath); - if (isDefaultLib) { - file.isDefaultLib = true; - files.unshift(file); - } - else { - files.push(file); - } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + }); + filesByName.set(fileName, file); + if (file) { + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + // Set the source file for normalized absolute path + filesByName.set(normalizedAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); + if (!options.noResolve) { + processReferencedFiles(file, basePath); + } + // always process imported modules to record module name resolutions + processImportedModules(file, basePath); + if (isDefaultLib) { + file.isDefaultLib = true; + files.unshift(file); + } + else { + files.push(file); } - return file; } - function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) { - var file = filesByName.get(canonicalName); + return file; + function getSourceFileFromCache(fileName, useAbsolutePath) { + var file = filesByName.get(fileName); if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; - if (canonicalName !== sourceFileName) { + if (ts.normalizeSlashes(fileName) !== ts.normalizeSlashes(sourceFileName)) { if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); } @@ -36138,9 +36838,9 @@ var ts; var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } - // Cannot specify module gen target when in es6 or above - if (options.module && languageVersion >= 2 /* ES6 */) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); + // Cannot specify module gen target of es6 when below es6 + if (options.module === 5 /* ES6 */ && languageVersion < 2 /* ES6 */) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower)); } // there has to be common source directory if user specified --outdir || --sourceRoot // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted @@ -36181,10 +36881,6 @@ var ts; !options.experimentalDecorators) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } - if (options.experimentalAsyncFunctions && - options.target !== 2 /* ES6 */) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); - } } } ts.createProgram = createProgram; @@ -36266,11 +36962,12 @@ var ts; "commonjs": 1 /* CommonJS */, "amd": 2 /* AMD */, "system": 4 /* System */, - "umd": 3 /* UMD */ + "umd": 3 /* UMD */, + "es6": 5 /* ES6 */ }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_or_umd, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6 }, { name: "newLine", @@ -36412,11 +37109,6 @@ var ts; type: "boolean", description: ts.Diagnostics.Watch_input_files }, - { - name: "experimentalAsyncFunctions", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_async_functions - }, { name: "experimentalDecorators", type: "boolean", @@ -36622,6 +37314,9 @@ var ts; } if (opt.isFilePath) { value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } } options[opt.name] = value; } @@ -36650,20 +37345,20 @@ var ts; var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); for (var i = 0; i < sysFiles.length; i++) { - var name_27 = sysFiles[i]; - if (ts.fileExtensionIs(name_27, ".d.ts")) { - var baseName = name_27.substr(0, name_27.length - ".d.ts".length); + var name_28 = sysFiles[i]; + if (ts.fileExtensionIs(name_28, ".d.ts")) { + var baseName = name_28.substr(0, name_28.length - ".d.ts".length); if (!ts.contains(sysFiles, baseName + ".tsx") && !ts.contains(sysFiles, baseName + ".ts")) { - fileNames.push(name_27); + fileNames.push(name_28); } } - else if (ts.fileExtensionIs(name_27, ".ts")) { - if (!ts.contains(sysFiles, name_27 + "x")) { - fileNames.push(name_27); + else if (ts.fileExtensionIs(name_28, ".ts")) { + if (!ts.contains(sysFiles, name_28 + "x")) { + fileNames.push(name_28); } } else { - fileNames.push(name_27); + fileNames.push(name_28); } } } @@ -36744,7 +37439,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 172 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 174 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -36756,7 +37451,7 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 190 /* Block */: + case 192 /* Block */: if (!ts.isFunctionBlock(n)) { var parent_7 = n.parent; var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); @@ -36764,18 +37459,18 @@ var ts; // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collaps the block, but consider its hint span // to be the entire span of the parent. - if (parent_7.kind === 195 /* DoStatement */ || - parent_7.kind === 198 /* ForInStatement */ || - parent_7.kind === 199 /* ForOfStatement */ || - parent_7.kind === 197 /* ForStatement */ || - parent_7.kind === 194 /* IfStatement */ || - parent_7.kind === 196 /* WhileStatement */ || - parent_7.kind === 203 /* WithStatement */ || - parent_7.kind === 242 /* CatchClause */) { + if (parent_7.kind === 197 /* DoStatement */ || + parent_7.kind === 200 /* ForInStatement */ || + parent_7.kind === 201 /* ForOfStatement */ || + parent_7.kind === 199 /* ForStatement */ || + parent_7.kind === 196 /* IfStatement */ || + parent_7.kind === 198 /* WhileStatement */ || + parent_7.kind === 205 /* WithStatement */ || + parent_7.kind === 244 /* CatchClause */) { addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_7.kind === 207 /* TryStatement */) { + if (parent_7.kind === 209 /* TryStatement */) { // Could be the try-block, or the finally-block. var tryStatement = parent_7; if (tryStatement.tryBlock === n) { @@ -36783,7 +37478,7 @@ var ts; break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -36802,23 +37497,23 @@ var ts; break; } // Fallthrough. - case 217 /* ModuleBlock */: { + case 219 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 163 /* ObjectLiteralExpression */: - case 218 /* CaseBlock */: { + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 165 /* ObjectLiteralExpression */: + case 220 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -36846,12 +37541,12 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_28 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_28); + for (var name_29 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_29); if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_28); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_29); if (!matches) { continue; } @@ -36864,14 +37559,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_28); + matches = patternMatcher.getMatches(containers, name_29); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_28, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_29, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -36895,7 +37590,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 67 /* Identifier */ || + if (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { return node.text; @@ -36909,7 +37604,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 134 /* ComputedPropertyName */) { + else if (declaration.name.kind === 136 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ true); } else { @@ -36930,7 +37625,7 @@ var ts; } return true; } - if (expression.kind === 164 /* PropertyAccessExpression */) { + if (expression.kind === 166 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -36943,7 +37638,7 @@ var ts; var containers = []; // First, if we started with a computed property name, then add all but the last // portion into the container array. - if (declaration.name.kind === 134 /* ComputedPropertyName */) { + if (declaration.name.kind === 136 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ false)) { return undefined; } @@ -37019,17 +37714,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: // If we have a module declared as A.B.C, it is more "intuitive" // to say it only has a single layer of depth do { current = current.parent; - } while (current.kind === 216 /* ModuleDeclaration */); + } while (current.kind === 218 /* ModuleDeclaration */); // fall through - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: - case 213 /* InterfaceDeclaration */: - case 211 /* FunctionDeclaration */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -37040,21 +37735,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 159 /* ObjectBindingPattern */: - case 160 /* ArrayBindingPattern */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -37066,7 +37761,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -37075,21 +37770,21 @@ var ts; } } break; - case 161 /* BindingElement */: - case 209 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 211 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: - case 213 /* InterfaceDeclaration */: - case 216 /* ModuleDeclaration */: - case 211 /* FunctionDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 224 /* ImportSpecifier */: - case 228 /* ExportSpecifier */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: + case 218 /* ModuleDeclaration */: + case 213 /* FunctionDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: childNodes.push(node); break; } @@ -37137,17 +37832,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: - case 213 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -37158,12 +37853,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 211 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 213 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 190 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 192 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 211 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 213 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -37223,7 +37918,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 136 /* Parameter */: + case 138 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } @@ -37231,36 +37926,36 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 143 /* GetAccessor */: + case 145 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 144 /* SetAccessor */: + case 146 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 147 /* IndexSignature */: + case 149 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 245 /* EnumMember */: + case 247 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 145 /* CallSignature */: + case 147 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 146 /* ConstructSignature */: + case 148 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: var variableDeclarationNode; - var name_29; - if (node.kind === 161 /* BindingElement */) { - name_29 = node.name; + var name_30; + if (node.kind === 163 /* BindingElement */) { + name_30 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 209 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 211 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -37268,24 +37963,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_29 = node.name; + name_30 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.variableElement); } - case 142 /* Constructor */: + case 144 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 228 /* ExportSpecifier */: - case 224 /* ImportSpecifier */: - case 219 /* ImportEqualsDeclaration */: - case 221 /* ImportClause */: - case 222 /* NamespaceImport */: + case 230 /* ExportSpecifier */: + case 226 /* ImportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -37315,17 +38010,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 246 /* SourceFile */: + case 248 /* SourceFile */: return createSourceFileItem(node); - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: return createClassItem(node); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return createEnumItem(node); - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return createModuleItem(node); - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; @@ -37337,7 +38032,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 218 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -37349,7 +38044,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.body && node.body.kind === 190 /* Block */) { + if (node.body && node.body.kind === 192 /* Block */) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -37370,7 +38065,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 142 /* Constructor */ && member; + return member.kind === 144 /* Constructor */ && member; }); // Add the constructor parameters in as children of the class (for property parameters). // Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that @@ -37394,7 +38089,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 134 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 136 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -37403,13 +38098,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 216 /* ModuleDeclaration */) { + while (node.body.kind === 218 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 246 /* SourceFile */ + return node.kind === 248 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -38197,22 +38892,22 @@ var ts; if (!candidates.length) { // We didn't have any sig help items produced by the TS compiler. If this is a JS // file, then see if we can figure out anything better. - if (ts.isJavaScript(sourceFile.fileName)) { + if (ts.isSourceFileJavaScript(sourceFile)) { return createJavaScriptSignatureHelpItems(argumentInfo); } return undefined; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 166 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 168 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 67 /* Identifier */ + var name = expression.kind === 69 /* Identifier */ ? expression - : expression.kind === 164 /* PropertyAccessExpression */ + : expression.kind === 166 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -38245,7 +38940,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 166 /* CallExpression */ || node.parent.kind === 167 /* NewExpression */) { + if (node.parent.kind === 168 /* CallExpression */ || node.parent.kind === 169 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -38298,25 +38993,25 @@ var ts; }; } } - else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 168 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 170 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0); } } - else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 168 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 170 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 183 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 188 /* TemplateSpan */ && node.parent.parent.parent.kind === 168 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 190 /* TemplateSpan */ && node.parent.parent.parent.kind === 170 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 183 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -38434,7 +39129,7 @@ var ts; // // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 181 /* TemplateExpression */) { + if (template.kind === 183 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -38443,7 +39138,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 246 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 248 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -38643,40 +39338,40 @@ var ts; return false; } switch (n.kind) { - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 163 /* ObjectLiteralExpression */: - case 159 /* ObjectBindingPattern */: - case 153 /* TypeLiteral */: - case 190 /* Block */: - case 217 /* ModuleBlock */: - case 218 /* CaseBlock */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 165 /* ObjectLiteralExpression */: + case 161 /* ObjectBindingPattern */: + case 155 /* TypeLiteral */: + case 192 /* Block */: + case 219 /* ModuleBlock */: + case 220 /* CaseBlock */: return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 167 /* NewExpression */: + case 169 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 166 /* CallExpression */: - case 170 /* ParenthesizedExpression */: - case 158 /* ParenthesizedType */: + case 168 /* CallExpression */: + case 172 /* ParenthesizedExpression */: + case 160 /* ParenthesizedType */: return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 146 /* ConstructSignature */: - case 145 /* CallSignature */: - case 172 /* ArrowFunction */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 148 /* ConstructSignature */: + case 147 /* CallSignature */: + case 174 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -38686,63 +39381,64 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 18 /* CloseParenToken */, sourceFile); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 194 /* IfStatement */: + case 196 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 193 /* ExpressionStatement */: - return isCompletedNode(n.expression, sourceFile); - case 162 /* ArrayLiteralExpression */: - case 160 /* ArrayBindingPattern */: - case 165 /* ElementAccessExpression */: - case 134 /* ComputedPropertyName */: - case 155 /* TupleType */: + case 195 /* ExpressionStatement */: + return isCompletedNode(n.expression, sourceFile) || + hasChildOfKind(n, 23 /* SemicolonToken */); + case 164 /* ArrayLiteralExpression */: + case 162 /* ArrayBindingPattern */: + case 167 /* ElementAccessExpression */: + case 136 /* ComputedPropertyName */: + case 157 /* TupleType */: return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); - case 147 /* IndexSignature */: + case 149 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); - case 239 /* CaseClause */: - case 240 /* DefaultClause */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 196 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 198 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 195 /* DoStatement */: + case 197 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - var hasWhileKeyword = findChildOfKind(n, 102 /* WhileKeyword */, sourceFile); + var hasWhileKeyword = findChildOfKind(n, 104 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 174 /* TypeOfExpression */: - case 173 /* DeleteExpression */: - case 175 /* VoidExpression */: - case 182 /* YieldExpression */: - case 183 /* SpreadElementExpression */: + case 176 /* TypeOfExpression */: + case 175 /* DeleteExpression */: + case 177 /* VoidExpression */: + case 184 /* YieldExpression */: + case 185 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 168 /* TaggedTemplateExpression */: + case 170 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 181 /* TemplateExpression */: + case 183 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 188 /* TemplateSpan */: + case 190 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -38798,7 +39494,7 @@ var ts; // for the position of the relevant node (or comma). var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { // find syntax list that covers the span of the node - if (c.kind === 269 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 271 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -38904,7 +39600,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n) || n.kind === 234 /* JsxText */) { + if (isToken(n) || n.kind === 236 /* JsxText */) { return n; } var children = n.getChildren(); @@ -38912,7 +39608,7 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n) || n.kind === 234 /* JsxText */) { + if (isToken(n) || n.kind === 236 /* JsxText */) { return n; } var children = n.getChildren(); @@ -38926,10 +39622,10 @@ var ts; // if no - position is in the node itself so we should recurse in it. // NOTE: JsxText is a weird kind of node that can contain only whitespaces (since they are not counted as trivia). // if this is the case - then we should assume that token in question is located in previous child. - if (position < child.end && (nodeHasTokens(child) || child.kind === 234 /* JsxText */)) { + if (position < child.end && (nodeHasTokens(child) || child.kind === 236 /* JsxText */)) { var start = child.getStart(sourceFile); var lookInPreviousChild = (start >= position) || - (child.kind === 234 /* JsxText */ && start === child.end); // whitespace only JsxText + (child.kind === 236 /* JsxText */ && start === child.end); // whitespace only JsxText if (lookInPreviousChild) { // actual start of the node is past the position - previous token should be at the end of previous child var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); @@ -38941,7 +39637,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 246 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 248 /* SourceFile */); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -39016,9 +39712,9 @@ var ts; var node = ts.getTokenAtPosition(sourceFile, position); if (isToken(node)) { switch (node.kind) { - case 100 /* VarKeyword */: - case 106 /* LetKeyword */: - case 72 /* ConstKeyword */: + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: // if the current token is var, let or const, skip the VariableDeclarationList node = node.parent === undefined ? undefined : node.parent.parent; break; @@ -39067,21 +39763,21 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 149 /* TypeReference */ || node.kind === 166 /* CallExpression */) { + if (node.kind === 151 /* TypeReference */ || node.kind === 168 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 212 /* ClassDeclaration */ || node.kind === 213 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 214 /* ClassDeclaration */ || node.kind === 215 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 132 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 134 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { - return kind === 67 /* Identifier */ || ts.isKeyword(kind); + return kind === 69 /* Identifier */ || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { @@ -39091,8 +39787,17 @@ var ts; return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; } ts.isComment = isComment; + function isStringOrRegularExpressionOrTemplateLiteral(kind) { + if (kind === 9 /* StringLiteral */ + || kind === 10 /* RegularExpressionLiteral */ + || ts.isTemplateLiteralKind(kind)) { + return true; + } + return false; + } + ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 15 /* FirstPunctuation */ <= kind && kind <= 66 /* LastPunctuation */; + return 15 /* FirstPunctuation */ <= kind && kind <= 68 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -39102,9 +39807,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: return true; } return false; @@ -39132,7 +39837,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 136 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 138 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -39154,7 +39859,8 @@ var ts; increaseIndent: function () { indent++; }, decreaseIndent: function () { indent--; }, clear: resetWriter, - trackSymbol: function () { } + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } }; function writeIndent() { if (lineStart) { @@ -39319,7 +40025,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 224 /* ImportSpecifier */ || location.parent.kind === 228 /* ExportSpecifier */) && + (location.parent.kind === 226 /* ImportSpecifier */ || location.parent.kind === 230 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -39347,7 +40053,12 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false); + var standardScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + var jsxScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); + /** + * Scanner that is currently used for formatting + */ + var scanner; var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; @@ -39357,6 +40068,8 @@ var ts; ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; })(ScanAction || (ScanAction = {})); function getFormattingScanner(sourceFile, startPos, endPos) { + ts.Debug.assert(scanner === undefined); + scanner = sourceFile.languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; scanner.setText(sourceFile.text); scanner.setTextPos(startPos); var wasNewLine = true; @@ -39371,11 +40084,14 @@ var ts; isOnToken: isOnToken, lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, close: function () { + ts.Debug.assert(scanner !== undefined); lastTokenInfo = undefined; scanner.setText(undefined); + scanner = undefined; } }; function advance() { + ts.Debug.assert(scanner !== undefined); lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { @@ -39419,10 +40135,10 @@ var ts; if (node) { switch (node.kind) { case 29 /* GreaterThanEqualsToken */: - case 62 /* GreaterThanGreaterThanEqualsToken */: - case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 44 /* GreaterThanGreaterThanGreaterThanToken */: - case 43 /* GreaterThanGreaterThanToken */: + case 64 /* GreaterThanGreaterThanEqualsToken */: + case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 45 /* GreaterThanGreaterThanGreaterThanToken */: + case 44 /* GreaterThanGreaterThanToken */: return true; } } @@ -39431,11 +40147,11 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 236 /* JsxAttribute */: - case 233 /* JsxOpeningElement */: - case 235 /* JsxClosingElement */: - case 232 /* JsxSelfClosingElement */: - return node.kind === 67 /* Identifier */; + case 238 /* JsxAttribute */: + case 235 /* JsxOpeningElement */: + case 237 /* JsxClosingElement */: + case 234 /* JsxSelfClosingElement */: + return node.kind === 69 /* Identifier */; } } return false; @@ -39448,9 +40164,10 @@ var ts; container.kind === 14 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 38 /* SlashToken */ || t === 59 /* SlashEqualsToken */; + return t === 39 /* SlashToken */ || t === 61 /* SlashEqualsToken */; } function readTokenInfo(n) { + ts.Debug.assert(scanner !== undefined); if (!isOnToken()) { // scanner is not on the token (either advance was not called yet or scanner is already past the end position) return { @@ -39500,7 +40217,7 @@ var ts; currentToken = scanner.reScanTemplateToken(); lastScanAction = 3 /* RescanTemplateToken */; } - else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 67 /* Identifier */) { + else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 69 /* Identifier */) { currentToken = scanner.scanJsxIdentifier(); lastScanAction = 4 /* RescanJsxIdentifier */; } @@ -39544,6 +40261,7 @@ var ts; return fixTokenKind(lastTokenInfo, n); } function isOnToken() { + ts.Debug.assert(scanner !== undefined); var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); @@ -39822,17 +40540,17 @@ var ts; this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2 /* SingleLineCommentTrivia */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1 /* Ignore */)); // Space after keyword but not before ; or : or ? this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Space after }. this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 78 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 102 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 80 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 104 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 20 /* CloseBracketToken */, 24 /* CommaToken */, 23 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // No space for dot this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); @@ -39844,10 +40562,10 @@ var ts; this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 3 /* MultiLineCommentTrivia */, 71 /* ClassKeyword */]); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 3 /* MultiLineCommentTrivia */, 73 /* ClassKeyword */]); this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a control flow construct - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 77 /* DoKeyword */, 98 /* TryKeyword */, 83 /* FinallyKeyword */, 78 /* ElseKeyword */]); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 79 /* DoKeyword */, 100 /* TryKeyword */, 85 /* FinallyKeyword */, 80 /* ElseKeyword */]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); @@ -39861,55 +40579,55 @@ var ts; // Prefix operators generally shouldn't have a space between // them and their target unary expression. this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100 /* VarKeyword */, 96 /* ThrowKeyword */, 90 /* NewKeyword */, 76 /* DeleteKeyword */, 92 /* ReturnKeyword */, 99 /* TypeOfKeyword */, 117 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106 /* LetKeyword */, 72 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([102 /* VarKeyword */, 98 /* ThrowKeyword */, 92 /* NewKeyword */, 78 /* DeleteKeyword */, 94 /* ReturnKeyword */, 101 /* TypeOfKeyword */, 119 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([108 /* LetKeyword */, 74 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(87 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(101 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(92 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 77 /* DoKeyword */, 78 /* ElseKeyword */, 69 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 79 /* DoKeyword */, 80 /* ElseKeyword */, 71 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([98 /* TryKeyword */, 83 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([100 /* TryKeyword */, 85 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([121 /* GetKeyword */, 127 /* SetKeyword */]), 67 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* GetKeyword */, 129 /* SetKeyword */]), 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. 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 /* Space */)); 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 /* Space */)); // TypeScript-specific higher priority rules // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(119 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* ModuleKeyword */, 125 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125 /* ModuleKeyword */, 127 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 71 /* ClassKeyword */, 120 /* DeclareKeyword */, 75 /* DefaultKeyword */, 79 /* EnumKeyword */, 80 /* ExportKeyword */, 81 /* ExtendsKeyword */, 121 /* GetKeyword */, 104 /* ImplementsKeyword */, 87 /* ImportKeyword */, 105 /* InterfaceKeyword */, 123 /* ModuleKeyword */, 124 /* NamespaceKeyword */, 108 /* PrivateKeyword */, 110 /* PublicKeyword */, 109 /* ProtectedKeyword */, 127 /* SetKeyword */, 111 /* StaticKeyword */, 130 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([81 /* ExtendsKeyword */, 104 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 73 /* ClassKeyword */, 122 /* DeclareKeyword */, 77 /* DefaultKeyword */, 81 /* EnumKeyword */, 82 /* ExportKeyword */, 83 /* ExtendsKeyword */, 123 /* GetKeyword */, 106 /* ImplementsKeyword */, 89 /* ImportKeyword */, 107 /* InterfaceKeyword */, 125 /* ModuleKeyword */, 126 /* NamespaceKeyword */, 110 /* PrivateKeyword */, 112 /* PublicKeyword */, 111 /* ProtectedKeyword */, 129 /* SetKeyword */, 113 /* StaticKeyword */, 132 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83 /* ExtendsKeyword */, 106 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Optional parameters and let args - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 67 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); // generics and type assertions this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseParenToken */, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); @@ -39920,17 +40638,20 @@ var ts; // Remove spaces in empty interface literals. e.g.: x: {} this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); // decorators - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 67 /* Identifier */, 80 /* ExportKeyword */, 75 /* DefaultKeyword */, 71 /* ClassKeyword */, 111 /* StaticKeyword */, 110 /* PublicKeyword */, 108 /* PrivateKeyword */, 109 /* ProtectedKeyword */, 121 /* GetKeyword */, 127 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 69 /* Identifier */, 82 /* ExportKeyword */, 77 /* DefaultKeyword */, 73 /* ClassKeyword */, 113 /* StaticKeyword */, 112 /* PublicKeyword */, 110 /* PrivateKeyword */, 111 /* ProtectedKeyword */, 123 /* GetKeyword */, 129 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); // Async-await - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 87 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // template string - this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12 /* TemplateHead */, 13 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13 /* TemplateMiddle */, 14 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ @@ -39957,8 +40678,8 @@ var ts; this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, - this.SpaceBetweenAsyncAndFunctionKeyword, - this.SpaceBetweenTagAndTemplateString, + this.SpaceBetweenAsyncAndOpenParen, this.SpaceBetweenAsyncAndFunctionKeyword, + this.SpaceBetweenTagAndTemplateString, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail, // TypeScript-specific rules this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, @@ -40026,14 +40747,14 @@ var ts; this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Insert space after function keyword for anonymous functions - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_30 in o) { - if (o[name_30] === rule) { - return name_30; + for (var name_31 in o) { + if (o[name_31] === rule) { + return name_31; } } throw new Error("Unknown rule"); @@ -40042,40 +40763,40 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 197 /* ForStatement */; + return context.contextNode.kind === 199 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 179 /* BinaryExpression */: - case 180 /* ConditionalExpression */: - case 187 /* AsExpression */: - case 148 /* TypePredicate */: - case 156 /* UnionType */: - case 157 /* IntersectionType */: + case 181 /* BinaryExpression */: + case 182 /* ConditionalExpression */: + case 189 /* AsExpression */: + case 150 /* TypePredicate */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 161 /* BindingElement */: + case 163 /* BindingElement */: // equals in type X = ... - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 209 /* VariableDeclaration */: + case 211 /* VariableDeclaration */: // equal in p = 0; - case 136 /* Parameter */: - case 245 /* EnumMember */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - return context.currentTokenSpan.kind === 55 /* EqualsToken */ || context.nextTokenSpan.kind === 55 /* EqualsToken */; + case 138 /* Parameter */: + case 247 /* EnumMember */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return context.currentTokenSpan.kind === 56 /* EqualsToken */ || context.nextTokenSpan.kind === 56 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 198 /* ForInStatement */: - return context.currentTokenSpan.kind === 88 /* InKeyword */ || context.nextTokenSpan.kind === 88 /* InKeyword */; + case 200 /* ForInStatement */: + return context.currentTokenSpan.kind === 90 /* InKeyword */ || context.nextTokenSpan.kind === 90 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 199 /* ForOfStatement */: - return context.currentTokenSpan.kind === 132 /* OfKeyword */ || context.nextTokenSpan.kind === 132 /* OfKeyword */; + case 201 /* ForOfStatement */: + return context.currentTokenSpan.kind === 134 /* OfKeyword */ || context.nextTokenSpan.kind === 134 /* OfKeyword */; } return false; }; @@ -40083,7 +40804,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 180 /* ConditionalExpression */; + return context.contextNode.kind === 182 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -40127,93 +40848,93 @@ var ts; return true; } switch (node.kind) { - case 190 /* Block */: - case 218 /* CaseBlock */: - case 163 /* ObjectLiteralExpression */: - case 217 /* ModuleBlock */: + case 192 /* Block */: + case 220 /* CaseBlock */: + case 165 /* ObjectLiteralExpression */: + case 219 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 145 /* CallSignature */: - case 171 /* FunctionExpression */: - case 142 /* Constructor */: - case 172 /* ArrowFunction */: + case 147 /* CallSignature */: + case 173 /* FunctionExpression */: + case 144 /* Constructor */: + case 174 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 211 /* FunctionDeclaration */ || context.contextNode.kind === 171 /* FunctionExpression */; + return context.contextNode.kind === 213 /* FunctionDeclaration */ || context.contextNode.kind === 173 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 153 /* TypeLiteral */: - case 216 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 155 /* TypeLiteral */: + case 218 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 212 /* ClassDeclaration */: - case 216 /* ModuleDeclaration */: - case 215 /* EnumDeclaration */: - case 190 /* Block */: - case 242 /* CatchClause */: - case 217 /* ModuleBlock */: - case 204 /* SwitchStatement */: + case 214 /* ClassDeclaration */: + case 218 /* ModuleDeclaration */: + case 217 /* EnumDeclaration */: + case 192 /* Block */: + case 244 /* CatchClause */: + case 219 /* ModuleBlock */: + case 206 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 194 /* IfStatement */: - case 204 /* SwitchStatement */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 196 /* WhileStatement */: - case 207 /* TryStatement */: - case 195 /* DoStatement */: - case 203 /* WithStatement */: + case 196 /* IfStatement */: + case 206 /* SwitchStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 198 /* WhileStatement */: + case 209 /* TryStatement */: + case 197 /* DoStatement */: + case 205 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 242 /* CatchClause */: + case 244 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 163 /* ObjectLiteralExpression */; + return context.contextNode.kind === 165 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 166 /* CallExpression */; + return context.contextNode.kind === 168 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 167 /* NewExpression */; + return context.contextNode.kind === 169 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -40221,6 +40942,9 @@ var ts; Rules.IsPreviousTokenNotComma = function (context) { return context.currentTokenSpan.kind !== 24 /* CommaToken */; }; + Rules.IsArrowFunctionContext = function (context) { + return context.contextNode.kind === 174 /* ArrowFunction */; + }; Rules.IsSameLineTokenContext = function (context) { return context.TokensAreOnSameLine(); }; @@ -40237,41 +40961,41 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 137 /* Decorator */; + return node.kind === 139 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 210 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 212 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 216 /* ModuleDeclaration */; + return context.contextNode.kind === 218 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 153 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 155 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 149 /* TypeReference */: - case 169 /* TypeAssertionExpression */: - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 213 /* InterfaceDeclaration */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 186 /* ExpressionWithTypeArguments */: + case 151 /* TypeReference */: + case 171 /* TypeAssertionExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 188 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -40282,13 +41006,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 169 /* TypeAssertionExpression */; + return context.contextNode.kind === 171 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 101 /* VoidKeyword */ && context.currentTokenParent.kind === 175 /* VoidExpression */; + return context.currentTokenSpan.kind === 103 /* VoidKeyword */ && context.currentTokenParent.kind === 177 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 182 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 184 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -40312,7 +41036,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 132 /* LastToken */ + 1; + this.mapRowLength = 134 /* LastToken */ + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); //new Array(this.mapRowLength * this.mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(this.map.length); //new Array(this.map.length); @@ -40507,7 +41231,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 132 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 134 /* LastToken */; token++) { result.push(token); } return result; @@ -40549,17 +41273,17 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(68 /* FirstKeyword */, 132 /* LastKeyword */); - TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 66 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([88 /* InKeyword */, 89 /* InstanceOfKeyword */, 132 /* OfKeyword */, 114 /* AsKeyword */, 122 /* IsKeyword */]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([40 /* PlusPlusToken */, 41 /* MinusMinusToken */, 49 /* TildeToken */, 48 /* ExclamationToken */]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 67 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]); + TokenRange.Keywords = TokenRange.FromRange(70 /* FirstKeyword */, 134 /* LastKeyword */); + TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 68 /* LastBinaryOperator */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90 /* InKeyword */, 91 /* InstanceOfKeyword */, 134 /* OfKeyword */, 116 /* AsKeyword */, 124 /* IsKeyword */]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41 /* PlusPlusToken */, 42 /* MinusMinusToken */, 50 /* TildeToken */, 49 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 69 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([67 /* Identifier */, 126 /* NumberKeyword */, 128 /* StringKeyword */, 118 /* BooleanKeyword */, 129 /* SymbolKeyword */, 101 /* VoidKeyword */, 115 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([69 /* Identifier */, 128 /* NumberKeyword */, 130 /* StringKeyword */, 120 /* BooleanKeyword */, 131 /* SymbolKeyword */, 103 /* VoidKeyword */, 117 /* AnyKeyword */]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -40773,17 +41497,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 190 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 246 /* SourceFile */: - case 190 /* Block */: - case 217 /* ModuleBlock */: + return body && body.kind === 192 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 248 /* SourceFile */: + case 192 /* Block */: + case 219 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -40956,9 +41680,9 @@ var ts; // - source file // - switch\default clauses if (isSomeBlock(parent.kind) || - parent.kind === 246 /* SourceFile */ || - parent.kind === 239 /* CaseClause */ || - parent.kind === 240 /* DefaultClause */) { + parent.kind === 248 /* SourceFile */ || + parent.kind === 241 /* CaseClause */ || + parent.kind === 242 /* DefaultClause */) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -40994,19 +41718,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 212 /* ClassDeclaration */: return 71 /* ClassKeyword */; - case 213 /* InterfaceDeclaration */: return 105 /* InterfaceKeyword */; - case 211 /* FunctionDeclaration */: return 85 /* FunctionKeyword */; - case 215 /* EnumDeclaration */: return 215 /* EnumDeclaration */; - case 143 /* GetAccessor */: return 121 /* GetKeyword */; - case 144 /* SetAccessor */: return 127 /* SetKeyword */; - case 141 /* MethodDeclaration */: + case 214 /* ClassDeclaration */: return 73 /* ClassKeyword */; + case 215 /* InterfaceDeclaration */: return 107 /* InterfaceKeyword */; + case 213 /* FunctionDeclaration */: return 87 /* FunctionKeyword */; + case 217 /* EnumDeclaration */: return 217 /* EnumDeclaration */; + case 145 /* GetAccessor */: return 123 /* GetKeyword */; + case 146 /* SetAccessor */: return 129 /* SetKeyword */; + case 143 /* MethodDeclaration */: if (node.asteriskToken) { return 37 /* AsteriskToken */; } // fall-through - case 139 /* PropertyDeclaration */: - case 136 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 138 /* Parameter */: return node.name.kind; } } @@ -41040,9 +41764,9 @@ var ts; case 20 /* CloseBracketToken */: case 17 /* OpenParenToken */: case 18 /* CloseParenToken */: - case 78 /* ElseKeyword */: - case 102 /* WhileKeyword */: - case 54 /* AtToken */: + case 80 /* ElseKeyword */: + case 104 /* WhileKeyword */: + case 55 /* AtToken */: return indentation; default: // if token line equals to the line of containing node (this is a first token in the node) - use node indentation @@ -41142,7 +41866,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 137 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 139 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -41399,8 +42123,8 @@ var ts; for (var line = line1; line < line2; ++line) { var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile); var lineEndPosition = ts.getEndLinePosition(line, sourceFile); - // do not trim whitespaces in comments - if (range && ts.isComment(range.kind) && range.pos <= lineEndPosition && range.end > lineEndPosition) { + // do not trim whitespaces in comments or template expression + if (range && (ts.isComment(range.kind) || ts.isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) { continue; } var pos = lineEndPosition; @@ -41466,20 +42190,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 190 /* Block */: - case 217 /* ModuleBlock */: + case 192 /* Block */: + case 219 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 142 /* Constructor */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 172 /* ArrowFunction */: + case 144 /* Constructor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 174 /* ArrowFunction */: if (node.typeParameters === list) { return 25 /* LessThanToken */; } @@ -41487,8 +42211,8 @@ var ts; return 17 /* OpenParenToken */; } break; - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: if (node.typeArguments === list) { return 25 /* LessThanToken */; } @@ -41496,7 +42220,7 @@ var ts; return 17 /* OpenParenToken */; } break; - case 149 /* TypeReference */: + case 151 /* TypeReference */: if (node.typeArguments === list) { return 25 /* LessThanToken */; } @@ -41580,22 +42304,39 @@ var ts; if (position > sourceFile.text.length) { return 0; // past EOF } + // no indentation when the indent style is set to none, + // so we can return fast + if (options.IndentStyle === ts.IndentStyle.None) { + return 0; + } var precedingToken = ts.findPrecedingToken(position, sourceFile); if (!precedingToken) { return 0; } // no indentation in string \regex\template literals - var precedingTokenIsLiteral = precedingToken.kind === 9 /* StringLiteral */ || - precedingToken.kind === 10 /* RegularExpressionLiteral */ || - precedingToken.kind === 11 /* NoSubstitutionTemplateLiteral */ || - precedingToken.kind === 12 /* TemplateHead */ || - precedingToken.kind === 13 /* TemplateMiddle */ || - precedingToken.kind === 14 /* TemplateTail */; + var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 179 /* BinaryExpression */) { + // indentation is first non-whitespace character in a previous line + // for block indentation, we should look for a line which contains something that's not + // whitespace. + if (options.IndentStyle === ts.IndentStyle.Block) { + // move backwards until we find a line with a non-whitespace character, + // then find the first non-whitespace character for that line. + var current_1 = position; + while (current_1 > 0) { + var char = sourceFile.text.charCodeAt(current_1); + if (!ts.isWhiteSpace(char) && !ts.isLineBreak(char)) { + break; + } + current_1--; + } + var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); + return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); + } + if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 181 /* BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { @@ -41714,7 +42455,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 246 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 248 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -41747,8 +42488,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 194 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 78 /* ElseKeyword */, sourceFile); + if (parent.kind === 196 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 80 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -41759,23 +42500,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 149 /* TypeReference */: + case 151 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return node.parent.properties; - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return node.parent.elements; - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: { + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -41786,8 +42527,8 @@ var ts; } break; } - case 167 /* NewExpression */: - case 166 /* CallExpression */: { + case 169 /* NewExpression */: + case 168 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -41817,8 +42558,8 @@ var ts; if (node.kind === 18 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 166 /* CallExpression */ || - node.parent.kind === 167 /* NewExpression */) && + if (node.parent && (node.parent.kind === 168 /* CallExpression */ || + node.parent.kind === 169 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -41836,10 +42577,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: node = node.expression; break; default: @@ -41904,42 +42645,43 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 162 /* ArrayLiteralExpression */: - case 190 /* Block */: - case 217 /* ModuleBlock */: - case 163 /* ObjectLiteralExpression */: - case 153 /* TypeLiteral */: - case 155 /* TupleType */: - case 218 /* CaseBlock */: - case 240 /* DefaultClause */: - case 239 /* CaseClause */: - case 170 /* ParenthesizedExpression */: - case 164 /* PropertyAccessExpression */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 191 /* VariableStatement */: - case 209 /* VariableDeclaration */: - case 225 /* ExportAssignment */: - case 202 /* ReturnStatement */: - case 180 /* ConditionalExpression */: - case 160 /* ArrayBindingPattern */: - case 159 /* ObjectBindingPattern */: - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - case 140 /* MethodSignature */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 136 /* Parameter */: - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 158 /* ParenthesizedType */: - case 168 /* TaggedTemplateExpression */: - case 176 /* AwaitExpression */: + case 195 /* ExpressionStatement */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 164 /* ArrayLiteralExpression */: + case 192 /* Block */: + case 219 /* ModuleBlock */: + case 165 /* ObjectLiteralExpression */: + case 155 /* TypeLiteral */: + case 157 /* TupleType */: + case 220 /* CaseBlock */: + case 242 /* DefaultClause */: + case 241 /* CaseClause */: + case 172 /* ParenthesizedExpression */: + case 166 /* PropertyAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 193 /* VariableStatement */: + case 211 /* VariableDeclaration */: + case 227 /* ExportAssignment */: + case 204 /* ReturnStatement */: + case 182 /* ConditionalExpression */: + case 162 /* ArrayBindingPattern */: + case 161 /* ObjectBindingPattern */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 142 /* MethodSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 138 /* Parameter */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 160 /* ParenthesizedType */: + case 170 /* TaggedTemplateExpression */: + case 178 /* AwaitExpression */: return true; } return false; @@ -41949,20 +42691,20 @@ var ts; return true; } switch (parent) { - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 197 /* ForStatement */: - case 194 /* IfStatement */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 141 /* MethodDeclaration */: - case 172 /* ArrowFunction */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - return child !== 190 /* Block */; + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 199 /* ForStatement */: + case 196 /* IfStatement */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 174 /* ArrowFunction */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + return child !== 192 /* Block */; default: return false; } @@ -42104,7 +42846,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(269 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); + var list = createNode(271 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -42123,7 +42865,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 133 /* FirstNode */) { + if (this.kind >= 135 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -42170,7 +42912,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 133 /* FirstNode */ ? child : child.getFirstToken(sourceFile); + return child.kind < 135 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -42178,7 +42920,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 133 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 135 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; })(); @@ -42227,7 +42969,7 @@ var ts; if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments - if (canUseParsedParamTagComments && declaration.kind === 136 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 138 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -42236,15 +42978,15 @@ var ts; }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 216 /* ModuleDeclaration */ && declaration.body.kind === 216 /* ModuleDeclaration */) { + if (declaration.kind === 218 /* ModuleDeclaration */ && declaration.body.kind === 218 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 216 /* ModuleDeclaration */ && declaration.parent.kind === 216 /* ModuleDeclaration */) { + while (declaration.kind === 218 /* ModuleDeclaration */ && declaration.parent.kind === 218 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 209 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 211 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); @@ -42588,9 +43330,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 134 /* ComputedPropertyName */) { + if (declaration.name.kind === 136 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 164 /* PropertyAccessExpression */) { + if (expr.kind === 166 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -42600,7 +43342,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 67 /* Identifier */ || + if (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { return node.text; @@ -42610,9 +43352,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -42632,60 +43374,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 215 /* EnumDeclaration */: - case 216 /* ModuleDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 228 /* ExportSpecifier */: - case 224 /* ImportSpecifier */: - case 219 /* ImportEqualsDeclaration */: - case 221 /* ImportClause */: - case 222 /* NamespaceImport */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 153 /* TypeLiteral */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 217 /* EnumDeclaration */: + case 218 /* ModuleDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 230 /* ExportSpecifier */: + case 226 /* ImportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 155 /* TypeLiteral */: addDeclaration(node); // fall through - case 142 /* Constructor */: - case 191 /* VariableStatement */: - case 210 /* VariableDeclarationList */: - case 159 /* ObjectBindingPattern */: - case 160 /* ArrayBindingPattern */: - case 217 /* ModuleBlock */: + case 144 /* Constructor */: + case 193 /* VariableStatement */: + case 212 /* VariableDeclarationList */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + case 219 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 190 /* Block */: + case 192 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 136 /* Parameter */: + case 138 /* Parameter */: // Only consider properties defined as constructor parameters if (!(node.flags & 112 /* AccessibilityModifier */)) { break; } // fall through - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 245 /* EnumMember */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 247 /* EnumMember */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: addDeclaration(node); break; - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -42697,7 +43439,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -42724,6 +43466,12 @@ var ts; HighlightSpanKind.reference = "reference"; HighlightSpanKind.writtenReference = "writtenReference"; })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); + (function (IndentStyle) { + IndentStyle[IndentStyle["None"] = 0] = "None"; + IndentStyle[IndentStyle["Block"] = 1] = "Block"; + IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; + })(ts.IndentStyle || (ts.IndentStyle = {})); + var IndentStyle = ts.IndentStyle; (function (SymbolDisplayPartKind) { SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; @@ -42901,16 +43649,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 171 /* FunctionExpression */) { + if (declaration.kind === 173 /* FunctionExpression */) { return true; } - if (declaration.kind !== 209 /* VariableDeclaration */ && declaration.kind !== 211 /* FunctionDeclaration */) { + if (declaration.kind !== 211 /* VariableDeclaration */ && declaration.kind !== 213 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { // Reached source file or module block - if (parent_8.kind === 246 /* SourceFile */ || parent_8.kind === 217 /* ModuleBlock */) { + if (parent_8.kind === 248 /* SourceFile */ || parent_8.kind === 219 /* ModuleBlock */) { return false; } } @@ -43047,8 +43795,8 @@ var ts; // We are not doing a full typecheck, we are not resolving the whole context, // so pass --noResolve to avoid reporting missing file errors. options.noResolve = true; - // Parse - var inputFileName = transpileOptions.fileName || "module.ts"; + // if jsx is specified then treat file as .tsx + var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); var sourceFile = ts.createSourceFile(inputFileName, input, options.target); if (transpileOptions.moduleName) { sourceFile.moduleName = transpileOptions.moduleName; @@ -43260,8 +44008,9 @@ var ts; }; } ts.createDocumentRegistry = createDocumentRegistry; - function preProcessFile(sourceText, readImportFiles) { + function preProcessFile(sourceText, readImportFiles, detectJavaScriptImports) { if (readImportFiles === void 0) { readImportFiles = true; } + if (detectJavaScriptImports === void 0) { detectJavaScriptImports = false; } var referencedFiles = []; var importedFiles = []; var ambientExternalModules; @@ -43295,125 +44044,75 @@ var ts; end: pos + importPath.length }); } - function processImport() { - scanner.setText(sourceText); - var token = scanner.scan(); - // Look for: - // import "mod"; - // import d from "mod" - // import {a as A } from "mod"; - // import * as NS from "mod" - // import d, {a, b as B} from "mod" - // import i = require("mod"); - // - // export * from "mod" - // export {a as b} from "mod" - // export import i = require("mod") - while (token !== 1 /* EndOfFileToken */) { - if (token === 120 /* DeclareKeyword */) { - // declare module "mod" - token = scanner.scan(); - if (token === 123 /* ModuleKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - recordAmbientExternalModule(); - continue; - } - } - } - else if (token === 87 /* ImportKeyword */) { + /** + * Returns true if at least one token was consumed from the stream + */ + function tryConsumeDeclare() { + var token = scanner.getToken(); + if (token === 122 /* DeclareKeyword */) { + // declare module "mod" + token = scanner.scan(); + if (token === 125 /* ModuleKeyword */) { token = scanner.scan(); if (token === 9 /* StringLiteral */) { - // import "mod"; - recordModuleName(); - continue; + recordAmbientExternalModule(); } - else { - if (token === 67 /* Identifier */ || ts.isKeyword(token)) { + } + return true; + } + return false; + } + /** + * Returns true if at least one token was consumed from the stream + */ + function tryConsumeImport() { + var token = scanner.getToken(); + if (token === 89 /* ImportKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import "mod"; + recordModuleName(); + return true; + } + else { + if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { token = scanner.scan(); - if (token === 131 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import d from "mod"; - recordModuleName(); - continue; - } - } - else if (token === 55 /* EqualsToken */) { - token = scanner.scan(); - if (token === 125 /* RequireKeyword */) { - token = scanner.scan(); - if (token === 17 /* OpenParenToken */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import i = require("mod"); - recordModuleName(); - continue; - } - } - } - } - else if (token === 24 /* CommaToken */) { - // consume comma and keep going - token = scanner.scan(); - } - else { - // unknown syntax - continue; + if (token === 9 /* StringLiteral */) { + // import d from "mod"; + recordModuleName(); + return true; } } - if (token === 15 /* OpenBraceToken */) { - token = scanner.scan(); - // consume "{ a as B, c, d as D}" clauses - while (token !== 16 /* CloseBraceToken */) { - token = scanner.scan(); - } - if (token === 16 /* CloseBraceToken */) { - token = scanner.scan(); - if (token === 131 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import {a as A} from "mod"; - // import d, {a, b as B} from "mod" - recordModuleName(); - } - } + else if (token === 56 /* EqualsToken */) { + if (tryConsumeRequireCall(/* skipCurrentToken */ true)) { + return true; } } - else if (token === 37 /* AsteriskToken */) { + else if (token === 24 /* CommaToken */) { + // consume comma and keep going token = scanner.scan(); - if (token === 114 /* AsKeyword */) { - token = scanner.scan(); - if (token === 67 /* Identifier */ || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 131 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import * as NS from "mod" - // import d, * as NS from "mod" - recordModuleName(); - } - } - } - } + } + else { + // unknown syntax + return true; } } - } - else if (token === 80 /* ExportKeyword */) { - token = scanner.scan(); if (token === 15 /* OpenBraceToken */) { token = scanner.scan(); // consume "{ a as B, c, d as D}" clauses - while (token !== 16 /* CloseBraceToken */) { + // make sure that it stops on EOF + while (token !== 16 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = scanner.scan(); } if (token === 16 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 131 /* FromKeyword */) { + if (token === 133 /* FromKeyword */) { token = scanner.scan(); if (token === 9 /* StringLiteral */) { - // export {a as A} from "mod"; - // export {a, b as B} from "mod" + // import {a as A} from "mod"; + // import d, {a, b as B} from "mod" recordModuleName(); } } @@ -43421,40 +44120,162 @@ var ts; } else if (token === 37 /* AsteriskToken */) { token = scanner.scan(); - if (token === 131 /* FromKeyword */) { + if (token === 116 /* AsKeyword */) { + token = scanner.scan(); + if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import * as NS from "mod" + // import d, * as NS from "mod" + recordModuleName(); + } + } + } + } + } + } + return true; + } + return false; + } + function tryConsumeExport() { + var token = scanner.getToken(); + if (token === 82 /* ExportKeyword */) { + token = scanner.scan(); + if (token === 15 /* OpenBraceToken */) { + token = scanner.scan(); + // consume "{ a as B, c, d as D}" clauses + // make sure it stops on EOF + while (token !== 16 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + token = scanner.scan(); + } + if (token === 16 /* CloseBraceToken */) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { token = scanner.scan(); if (token === 9 /* StringLiteral */) { - // export * from "mod" + // export {a as A} from "mod"; + // export {a, b as B} from "mod" recordModuleName(); } } } - else if (token === 87 /* ImportKeyword */) { + } + else if (token === 37 /* AsteriskToken */) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { token = scanner.scan(); - if (token === 67 /* Identifier */ || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 55 /* EqualsToken */) { - token = scanner.scan(); - if (token === 125 /* RequireKeyword */) { - token = scanner.scan(); - if (token === 17 /* OpenParenToken */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // export import i = require("mod"); - recordModuleName(); - } - } - } + if (token === 9 /* StringLiteral */) { + // export * from "mod" + recordModuleName(); + } + } + } + else if (token === 89 /* ImportKeyword */) { + token = scanner.scan(); + if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 56 /* EqualsToken */) { + if (tryConsumeRequireCall(/* skipCurrentToken */ true)) { + return true; } } } } + return true; + } + return false; + } + function tryConsumeRequireCall(skipCurrentToken) { + var token = skipCurrentToken ? scanner.scan() : scanner.getToken(); + if (token === 127 /* RequireKeyword */) { + token = scanner.scan(); + if (token === 17 /* OpenParenToken */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // require("mod"); + recordModuleName(); + } + } + return true; + } + return false; + } + function tryConsumeDefine() { + var token = scanner.getToken(); + if (token === 69 /* Identifier */ && scanner.getTokenValue() === "define") { + token = scanner.scan(); + if (token !== 17 /* OpenParenToken */) { + return true; + } + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // looks like define ("modname", ... - skip string literal and comma + token = scanner.scan(); + if (token === 24 /* CommaToken */) { + token = scanner.scan(); + } + else { + // unexpected token + return true; + } + } + // should be start of dependency list + if (token !== 19 /* OpenBracketToken */) { + return true; + } + // skip open bracket token = scanner.scan(); + var i = 0; + // scan until ']' or EOF + while (token !== 20 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + // record string literals as module names + if (token === 9 /* StringLiteral */) { + recordModuleName(); + i++; + } + token = scanner.scan(); + } + return true; + } + return false; + } + function processImports() { + scanner.setText(sourceText); + scanner.scan(); + // Look for: + // import "mod"; + // import d from "mod" + // import {a as A } from "mod"; + // import * as NS from "mod" + // import d, {a, b as B} from "mod" + // import i = require("mod"); + // + // export * from "mod" + // export {a as b} from "mod" + // export import i = require("mod") + // (for JavaScript files) require("mod") + while (true) { + if (scanner.getToken() === 1 /* EndOfFileToken */) { + break; + } + // check if at least one of alternative have moved scanner forward + if (tryConsumeDeclare() || + tryConsumeImport() || + tryConsumeExport() || + (detectJavaScriptImports && (tryConsumeRequireCall(/* skipCurrentToken */ false) || tryConsumeDefine()))) { + continue; + } + else { + scanner.scan(); + } } scanner.setText(undefined); } if (readImportFiles) { - processImport(); + processImports(); } processTripleSlashDirectives(); return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules }; @@ -43463,7 +44284,7 @@ var ts; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 205 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 207 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -43471,13 +44292,13 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 67 /* Identifier */ && - (node.parent.kind === 201 /* BreakStatement */ || node.parent.kind === 200 /* ContinueStatement */) && + return node.kind === 69 /* Identifier */ && + (node.parent.kind === 203 /* BreakStatement */ || node.parent.kind === 202 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 67 /* Identifier */ && - node.parent.kind === 205 /* LabeledStatement */ && + return node.kind === 69 /* Identifier */ && + node.parent.kind === 207 /* LabeledStatement */ && node.parent.label === node; } /** @@ -43485,7 +44306,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 205 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 207 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -43496,49 +44317,49 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 168 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 167 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 169 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 216 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 218 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 67 /* Identifier */ && + return node.kind === 69 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */ function isNameOfPropertyAssignment(node) { - return (node.kind === 67 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - (node.parent.kind === 243 /* PropertyAssignment */ || node.parent.kind === 244 /* ShorthandPropertyAssignment */) && node.parent.name === node; + return (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && + (node.parent.kind === 245 /* PropertyAssignment */ || node.parent.kind === 246 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 243 /* PropertyAssignment */: - case 245 /* EnumMember */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 216 /* ModuleDeclaration */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 245 /* PropertyAssignment */: + case 247 /* EnumMember */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 218 /* ModuleDeclaration */: return node.parent.name === node; - case 165 /* ElementAccessExpression */: + case 167 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } @@ -43597,7 +44418,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 68 /* FirstKeyword */; i <= 132 /* LastKeyword */; i++) { + for (var i = 70 /* FirstKeyword */; i <= 134 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -43612,17 +44433,17 @@ var ts; return undefined; } switch (node.kind) { - case 246 /* SourceFile */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 216 /* ModuleDeclaration */: + case 248 /* SourceFile */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 218 /* ModuleDeclaration */: return node; } } @@ -43630,38 +44451,38 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 216 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 212 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 213 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 214 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 215 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 209 /* VariableDeclaration */: + case 218 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 214 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 215 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 216 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 217 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 211 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 211 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 143 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 144 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 213 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 145 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 146 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 147 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 146 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 145 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 142 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 135 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 245 /* EnumMember */: return ScriptElementKind.variableElement; - case 136 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 219 /* ImportEqualsDeclaration */: - case 224 /* ImportSpecifier */: - case 221 /* ImportClause */: - case 228 /* ExportSpecifier */: - case 222 /* NamespaceImport */: + case 149 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 148 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 147 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 144 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 137 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 247 /* EnumMember */: return ScriptElementKind.variableElement; + case 138 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 221 /* ImportEqualsDeclaration */: + case 226 /* ImportSpecifier */: + case 223 /* ImportClause */: + case 230 /* ExportSpecifier */: + case 224 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -43885,7 +44706,7 @@ var ts; // For JavaScript files, we don't want to report the normal typescript semantic errors. // Instead, we just report errors for using TypeScript-only constructs from within a // JavaScript file. - if (ts.isJavaScript(fileName)) { + if (ts.isSourceFileJavaScript(targetSourceFile)) { return getJavaScriptSemanticDiagnostics(targetSourceFile); } // Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file. @@ -43907,44 +44728,44 @@ var ts; return false; } switch (node.kind) { - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 241 /* HeritageClause */: + case 243 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 104 /* ImplementsKeyword */) { + if (heritageClause.token === 106 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 171 /* FunctionExpression */: - case 211 /* FunctionDeclaration */: - case 172 /* ArrowFunction */: - case 211 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -43952,20 +44773,20 @@ var ts; return true; } break; - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 209 /* VariableDeclaration */: + case 211 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -43973,7 +44794,7 @@ var ts; return true; } break; - case 136 /* Parameter */: + case 138 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -43989,17 +44810,17 @@ var ts; return true; } break; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 169 /* TypeAssertionExpression */: + case 171 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 137 /* Decorator */: + case 139 /* Decorator */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -44025,18 +44846,18 @@ var ts; for (var _i = 0; _i < modifiers.length; _i++) { var modifier = modifiers[_i]; switch (modifier.kind) { - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 120 /* DeclareKeyword */: + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 122 /* DeclareKeyword */: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; // These are all legal modifiers. - case 111 /* StaticKeyword */: - case 80 /* ExportKeyword */: - case 72 /* ConstKeyword */: - case 75 /* DefaultKeyword */: - case 113 /* AbstractKeyword */: + case 113 /* StaticKeyword */: + case 82 /* ExportKeyword */: + case 74 /* ConstKeyword */: + case 77 /* DefaultKeyword */: + case 115 /* AbstractKeyword */: } } } @@ -44097,7 +44918,7 @@ var ts; var typeChecker = program.getTypeChecker(); var syntacticStart = new Date().getTime(); var sourceFile = getValidSourceFile(fileName); - var isJavaScriptFile = ts.isJavaScript(fileName); + var isJavaScriptFile = ts.isSourceFileJavaScript(sourceFile); var isJsDocTagName = false; var start = new Date().getTime(); var currentToken = ts.getTokenAtPosition(sourceFile, position); @@ -44122,9 +44943,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 267 /* JSDocTypeTag */: - case 265 /* JSDocParameterTag */: - case 266 /* JSDocReturnTag */: + case 269 /* JSDocTypeTag */: + case 267 /* JSDocParameterTag */: + case 268 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -44161,6 +44982,7 @@ var ts; var node = currentToken; var isRightOfDot = false; var isRightOfOpenTag = false; + var isStartingCloseTag = false; var location = ts.getTouchingPropertyName(sourceFile, position); if (contextToken) { // Bail out if this is a known invalid completion location @@ -44170,11 +44992,11 @@ var ts; } var parent_9 = contextToken.parent, kind = contextToken.kind; if (kind === 21 /* DotToken */) { - if (parent_9.kind === 164 /* PropertyAccessExpression */) { + if (parent_9.kind === 166 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_9.kind === 133 /* QualifiedName */) { + else if (parent_9.kind === 135 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -44184,9 +45006,14 @@ var ts; return undefined; } } - else if (kind === 25 /* LessThanToken */ && sourceFile.languageVariant === 1 /* JSX */) { - isRightOfOpenTag = true; - location = contextToken; + else if (sourceFile.languageVariant === 1 /* JSX */) { + if (kind === 25 /* LessThanToken */) { + isRightOfOpenTag = true; + location = contextToken; + } + else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 237 /* JsxClosingElement */) { + isStartingCloseTag = true; + } } } var semanticStart = new Date().getTime(); @@ -44207,6 +45034,12 @@ var ts; isMemberCompletion = true; isNewIdentifierLocation = false; } + else if (isStartingCloseTag) { + var tagName = contextToken.parent.parent.openingElement.tagName; + symbols = [typeChecker.getSymbolAtLocation(tagName)]; + isMemberCompletion = true; + isNewIdentifierLocation = false; + } else { // For JavaScript or TypeScript, if we're not after a dot, then just try to get the // global symbols in scope. These results should be valid for either language as @@ -44221,7 +45054,7 @@ var ts; // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */) { + if (node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */ || node.kind === 166 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -44277,7 +45110,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; - if ((jsxContainer.kind === 232 /* JsxSelfClosingElement */) || (jsxContainer.kind === 233 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 234 /* JsxSelfClosingElement */) || (jsxContainer.kind === 235 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -44343,49 +45176,64 @@ var ts; var start = new Date().getTime(); var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || isSolelyIdentifierDefinitionLocation(contextToken) || - isDotOfNumericLiteral(contextToken); + isDotOfNumericLiteral(contextToken) || + isInJsxText(contextToken); log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); return result; } + function isInJsxText(contextToken) { + if (contextToken.kind === 236 /* JsxText */) { + return true; + } + if (contextToken.kind === 27 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 235 /* JsxOpeningElement */) { + return true; + } + if (contextToken.parent.kind === 237 /* JsxClosingElement */ || contextToken.parent.kind === 234 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 233 /* JsxElement */; + } + } + return false; + } function isNewIdentifierDefinitionLocation(previousToken) { if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 24 /* CommaToken */: - return containingNodeKind === 166 /* CallExpression */ // func( a, | - || containingNodeKind === 142 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 167 /* NewExpression */ // new C(a, | - || containingNodeKind === 162 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 179 /* BinaryExpression */ // let x = (a, | - || containingNodeKind === 150 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 168 /* CallExpression */ // func( a, | + || containingNodeKind === 144 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 169 /* NewExpression */ // new C(a, | + || containingNodeKind === 164 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 181 /* BinaryExpression */ // let x = (a, | + || containingNodeKind === 152 /* FunctionType */; // var x: (s: string, list| case 17 /* OpenParenToken */: - return containingNodeKind === 166 /* CallExpression */ // func( | - || containingNodeKind === 142 /* Constructor */ // constructor( | - || containingNodeKind === 167 /* NewExpression */ // new C(a| - || containingNodeKind === 170 /* ParenthesizedExpression */ // let x = (a| - || containingNodeKind === 158 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 168 /* CallExpression */ // func( | + || containingNodeKind === 144 /* Constructor */ // constructor( | + || containingNodeKind === 169 /* NewExpression */ // new C(a| + || containingNodeKind === 172 /* ParenthesizedExpression */ // let x = (a| + || containingNodeKind === 160 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 19 /* OpenBracketToken */: - return containingNodeKind === 162 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 147 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 134 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 123 /* ModuleKeyword */: // module | - case 124 /* NamespaceKeyword */: + return containingNodeKind === 164 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 149 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 136 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 125 /* ModuleKeyword */: // module | + case 126 /* NamespaceKeyword */: return true; case 21 /* DotToken */: - return containingNodeKind === 216 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 218 /* ModuleDeclaration */; // module A.| case 15 /* OpenBraceToken */: - return containingNodeKind === 212 /* ClassDeclaration */; // class A{ | - case 55 /* EqualsToken */: - return containingNodeKind === 209 /* VariableDeclaration */ // let x = a| - || containingNodeKind === 179 /* BinaryExpression */; // x = a| + return containingNodeKind === 214 /* ClassDeclaration */; // class A{ | + case 56 /* EqualsToken */: + return containingNodeKind === 211 /* VariableDeclaration */ // let x = a| + || containingNodeKind === 181 /* BinaryExpression */; // x = a| case 12 /* TemplateHead */: - return containingNodeKind === 181 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 183 /* TemplateExpression */; // `aa ${| case 13 /* TemplateMiddle */: - return containingNodeKind === 188 /* TemplateSpan */; // `aa ${10} dd ${| - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - return containingNodeKind === 139 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 190 /* TemplateSpan */; // `aa ${10} dd ${| + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + return containingNodeKind === 141 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -44428,14 +45276,14 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 163 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 165 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 159 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 161 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -44481,9 +45329,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 223 /* NamedImports */ ? - 220 /* ImportDeclaration */ : - 226 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 225 /* NamedImports */ ? + 222 /* ImportDeclaration */ : + 228 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -44509,7 +45357,7 @@ var ts; case 15 /* OpenBraceToken */: // let x = { | case 24 /* CommaToken */: var parent_10 = contextToken.parent; - if (parent_10 && (parent_10.kind === 163 /* ObjectLiteralExpression */ || parent_10.kind === 159 /* ObjectBindingPattern */)) { + if (parent_10 && (parent_10.kind === 165 /* ObjectLiteralExpression */ || parent_10.kind === 161 /* ObjectBindingPattern */)) { return parent_10; } break; @@ -44527,8 +45375,8 @@ var ts; case 15 /* OpenBraceToken */: // import { | case 24 /* CommaToken */: switch (contextToken.parent.kind) { - case 223 /* NamedImports */: - case 227 /* NamedExports */: + case 225 /* NamedImports */: + case 229 /* NamedExports */: return contextToken.parent; } } @@ -44540,30 +45388,33 @@ var ts; var parent_11 = contextToken.parent; switch (contextToken.kind) { case 26 /* LessThanSlashToken */: - case 38 /* SlashToken */: - case 67 /* Identifier */: - case 236 /* JsxAttribute */: - case 237 /* JsxSpreadAttribute */: - if (parent_11 && (parent_11.kind === 232 /* JsxSelfClosingElement */ || parent_11.kind === 233 /* JsxOpeningElement */)) { + case 39 /* SlashToken */: + case 69 /* Identifier */: + case 238 /* JsxAttribute */: + case 239 /* JsxSpreadAttribute */: + if (parent_11 && (parent_11.kind === 234 /* JsxSelfClosingElement */ || parent_11.kind === 235 /* JsxOpeningElement */)) { return parent_11; } + else if (parent_11.kind === 238 /* JsxAttribute */) { + return parent_11.parent; + } break; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent_11 && ((parent_11.kind === 236 /* JsxAttribute */) || (parent_11.kind === 237 /* JsxSpreadAttribute */))) { + if (parent_11 && ((parent_11.kind === 238 /* JsxAttribute */) || (parent_11.kind === 239 /* JsxSpreadAttribute */))) { return parent_11.parent; } break; case 16 /* CloseBraceToken */: if (parent_11 && - parent_11.kind === 238 /* JsxExpression */ && + parent_11.kind === 240 /* JsxExpression */ && parent_11.parent && - (parent_11.parent.kind === 236 /* JsxAttribute */)) { + (parent_11.parent.kind === 238 /* JsxAttribute */)) { return parent_11.parent.parent; } - if (parent_11 && parent_11.kind === 237 /* JsxSpreadAttribute */) { + if (parent_11 && parent_11.kind === 239 /* JsxSpreadAttribute */) { return parent_11.parent; } break; @@ -44573,16 +45424,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: return true; } return false; @@ -44594,78 +45445,84 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 24 /* CommaToken */: - return containingNodeKind === 209 /* VariableDeclaration */ || - containingNodeKind === 210 /* VariableDeclarationList */ || - containingNodeKind === 191 /* VariableStatement */ || - containingNodeKind === 215 /* EnumDeclaration */ || + return containingNodeKind === 211 /* VariableDeclaration */ || + containingNodeKind === 212 /* VariableDeclarationList */ || + containingNodeKind === 193 /* VariableStatement */ || + containingNodeKind === 217 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 212 /* ClassDeclaration */ || - containingNodeKind === 184 /* ClassExpression */ || - containingNodeKind === 213 /* InterfaceDeclaration */ || - containingNodeKind === 160 /* ArrayBindingPattern */ || - containingNodeKind === 214 /* TypeAliasDeclaration */; // type Map, K, | + containingNodeKind === 214 /* ClassDeclaration */ || + containingNodeKind === 186 /* ClassExpression */ || + containingNodeKind === 215 /* InterfaceDeclaration */ || + containingNodeKind === 162 /* ArrayBindingPattern */ || + containingNodeKind === 216 /* TypeAliasDeclaration */; // type Map, K, | case 21 /* DotToken */: - return containingNodeKind === 160 /* ArrayBindingPattern */; // var [.| - case 53 /* ColonToken */: - return containingNodeKind === 161 /* BindingElement */; // var {x :html| + return containingNodeKind === 162 /* ArrayBindingPattern */; // var [.| + case 54 /* ColonToken */: + return containingNodeKind === 163 /* BindingElement */; // var {x :html| case 19 /* OpenBracketToken */: - return containingNodeKind === 160 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 162 /* ArrayBindingPattern */; // var [x| case 17 /* OpenParenToken */: - return containingNodeKind === 242 /* CatchClause */ || + return containingNodeKind === 244 /* CatchClause */ || isFunction(containingNodeKind); case 15 /* OpenBraceToken */: - return containingNodeKind === 215 /* EnumDeclaration */ || - containingNodeKind === 213 /* InterfaceDeclaration */ || - containingNodeKind === 153 /* TypeLiteral */; // let x : { | + return containingNodeKind === 217 /* EnumDeclaration */ || + containingNodeKind === 215 /* InterfaceDeclaration */ || + containingNodeKind === 155 /* TypeLiteral */; // let x : { | case 23 /* SemicolonToken */: - return containingNodeKind === 138 /* PropertySignature */ && + return containingNodeKind === 140 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 213 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 153 /* TypeLiteral */); // let x : { a; | + (contextToken.parent.parent.kind === 215 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 155 /* TypeLiteral */); // let x : { a; | case 25 /* LessThanToken */: - return containingNodeKind === 212 /* ClassDeclaration */ || - containingNodeKind === 184 /* ClassExpression */ || - containingNodeKind === 213 /* InterfaceDeclaration */ || - containingNodeKind === 214 /* TypeAliasDeclaration */ || + return containingNodeKind === 214 /* ClassDeclaration */ || + containingNodeKind === 186 /* ClassExpression */ || + containingNodeKind === 215 /* InterfaceDeclaration */ || + containingNodeKind === 216 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); - case 111 /* StaticKeyword */: - return containingNodeKind === 139 /* PropertyDeclaration */; + case 113 /* StaticKeyword */: + return containingNodeKind === 141 /* PropertyDeclaration */; case 22 /* DotDotDotToken */: - return containingNodeKind === 136 /* Parameter */ || + return containingNodeKind === 138 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 160 /* ArrayBindingPattern */); // var [...z| - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - return containingNodeKind === 136 /* Parameter */; - case 114 /* AsKeyword */: - containingNodeKind === 224 /* ImportSpecifier */ || - containingNodeKind === 228 /* ExportSpecifier */ || - containingNodeKind === 222 /* NamespaceImport */; - case 71 /* ClassKeyword */: - case 79 /* EnumKeyword */: - case 105 /* InterfaceKeyword */: - case 85 /* FunctionKeyword */: - case 100 /* VarKeyword */: - case 121 /* GetKeyword */: - case 127 /* SetKeyword */: - case 87 /* ImportKeyword */: - case 106 /* LetKeyword */: - case 72 /* ConstKeyword */: - case 112 /* YieldKeyword */: - case 130 /* TypeKeyword */: + contextToken.parent.parent.kind === 162 /* ArrayBindingPattern */); // var [...z| + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + return containingNodeKind === 138 /* Parameter */; + case 116 /* AsKeyword */: + return containingNodeKind === 226 /* ImportSpecifier */ || + containingNodeKind === 230 /* ExportSpecifier */ || + containingNodeKind === 224 /* NamespaceImport */; + case 73 /* ClassKeyword */: + case 81 /* EnumKeyword */: + case 107 /* InterfaceKeyword */: + case 87 /* FunctionKeyword */: + case 102 /* VarKeyword */: + case 123 /* GetKeyword */: + case 129 /* SetKeyword */: + case 89 /* ImportKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: + case 114 /* YieldKeyword */: + case 132 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. switch (contextToken.getText()) { + case "abstract": + case "async": case "class": - case "interface": + case "const": + case "declare": case "enum": case "function": - case "var": - case "static": + case "interface": case "let": - case "const": + case "private": + case "protected": + case "public": + case "static": + case "var": case "yield": return true; } @@ -44695,8 +45552,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_31 = element.propertyName || element.name; - exisingImportsOrExports[name_31.text] = true; + var name_32 = element.propertyName || element.name; + exisingImportsOrExports[name_32.text] = true; } if (ts.isEmpty(exisingImportsOrExports)) { return exportsOfModule; @@ -44717,9 +45574,9 @@ var ts; for (var _i = 0; _i < existingMembers.length; _i++) { var m = existingMembers[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 243 /* PropertyAssignment */ && - m.kind !== 244 /* ShorthandPropertyAssignment */ && - m.kind !== 161 /* BindingElement */) { + if (m.kind !== 245 /* PropertyAssignment */ && + m.kind !== 246 /* ShorthandPropertyAssignment */ && + m.kind !== 163 /* BindingElement */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -44727,7 +45584,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 161 /* BindingElement */ && m.propertyName) { + if (m.kind === 163 /* BindingElement */ && m.propertyName) { existingName = m.propertyName.text; } else { @@ -44754,7 +45611,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 236 /* JsxAttribute */) { + if (attr.kind === 238 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -44768,46 +45625,43 @@ var ts; return undefined; } var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; - var entries; if (isJsDocTagName) { // If the current position is a jsDoc tag name, only tag names should be provided for completion return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; } - if (isRightOfDot && ts.isJavaScript(fileName)) { - entries = getCompletionEntriesFromSymbols(symbols); - ts.addRange(entries, getJavaScriptCompletionEntries()); + var sourceFile = getValidSourceFile(fileName); + var entries = []; + if (isRightOfDot && ts.isSourceFileJavaScript(sourceFile)) { + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries); + ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, uniqueNames)); } else { if (!symbols || symbols.length === 0) { return undefined; } - entries = getCompletionEntriesFromSymbols(symbols); + getCompletionEntriesFromSymbols(symbols, entries); } // Add keywords if this is not a member completion list if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - function getJavaScriptCompletionEntries() { + function getJavaScriptCompletionEntries(sourceFile, uniqueNames) { var entries = []; - var allNames = {}; var target = program.getCompilerOptions().target; - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - var nameTable = getNameTable(sourceFile); - for (var name_32 in nameTable) { - if (!allNames[name_32]) { - allNames[name_32] = name_32; - var displayName = getCompletionEntryDisplayName(name_32, target, /*performCharacterChecks:*/ true); - if (displayName) { - var entry = { - name: displayName, - kind: ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; - entries.push(entry); - } + var nameTable = getNameTable(sourceFile); + for (var name_33 in nameTable) { + if (!uniqueNames[name_33]) { + uniqueNames[name_33] = name_33; + var displayName = getCompletionEntryDisplayName(name_33, target, /*performCharacterChecks:*/ true); + if (displayName) { + var entry = { + name: displayName, + kind: ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); } } } @@ -44845,25 +45699,24 @@ var ts; sortText: "0" }; } - function getCompletionEntriesFromSymbols(symbols) { + function getCompletionEntriesFromSymbols(symbols, entries) { var start = new Date().getTime(); - var entries = []; + var uniqueNames = {}; if (symbols) { - var nameToSymbol = {}; for (var _i = 0; _i < symbols.length; _i++) { var symbol = symbols[_i]; var entry = createCompletionEntry(symbol, location); if (entry) { var id = ts.escapeIdentifier(entry.name); - if (!ts.lookUp(nameToSymbol, id)) { + if (!ts.lookUp(uniqueNames, id)) { entries.push(entry); - nameToSymbol[id] = symbol; + uniqueNames[id] = id; } } } } log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start)); - return entries; + return uniqueNames; } } function getCompletionEntryDetails(fileName, position, entryName) { @@ -44906,7 +45759,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 186 /* ClassExpression */) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ScriptElementKind.enumElement; @@ -45008,7 +45861,7 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 164 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 166 /* PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -45017,7 +45870,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression; - if (location.kind === 166 /* CallExpression */ || location.kind === 167 /* NewExpression */) { + if (location.kind === 168 /* CallExpression */ || location.kind === 169 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -45030,10 +45883,11 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 167 /* NewExpression */ || callExpression.expression.kind === 93 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 169 /* NewExpression */ || callExpression.expression.kind === 95 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); - if (!ts.contains(allSignatures, signature.target || signature)) { - // Get the first signature if there + if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { + // Get the first signature if there is one -- allSignatures may contain + // either the original signature or its target, so check for either signature = allSignatures.length ? allSignatures[0] : undefined; } if (signature) { @@ -45047,7 +45901,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(90 /* NewKeyword */)); + displayParts.push(ts.keywordPart(92 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -45063,10 +45917,10 @@ var ts; case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(53 /* ColonToken */)); + displayParts.push(ts.punctuationPart(54 /* ColonToken */)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(90 /* NewKeyword */)); + displayParts.push(ts.keywordPart(92 /* NewKeyword */)); displayParts.push(ts.spacePart()); } if (!(type.flags & 65536 /* Anonymous */)) { @@ -45082,24 +45936,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 119 /* ConstructorKeyword */ && location.parent.kind === 142 /* Constructor */)) { + (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 144 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 142 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 144 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 142 /* Constructor */) { + if (functionDeclaration.kind === 144 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 145 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 147 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -45108,7 +45962,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 186 /* ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class @@ -45116,7 +45970,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(71 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(73 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -45124,37 +45978,37 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(105 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(107 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(130 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(132 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55 /* EqualsToken */)); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384 /* Enum */) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(72 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(74 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(79 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(81 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 216 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 67 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 124 /* NamespaceKeyword */ : 123 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 218 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 69 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 126 /* NamespaceKeyword */ : 125 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -45166,7 +46020,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(88 /* InKeyword */)); + displayParts.push(ts.keywordPart(90 /* InKeyword */)); displayParts.push(ts.spacePart()); if (symbol.parent) { // Class/Interface type parameter @@ -45177,13 +46031,13 @@ var ts; // Method/function type parameter var container = ts.getContainingFunction(location); if (container) { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 146 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(90 /* NewKeyword */)); + if (signatureDeclaration.kind === 148 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(92 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 145 /* CallSignature */ && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 147 /* CallSignature */ && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -45192,8 +46046,8 @@ var ts; // Type aliash type parameter // For example // type list = T[]; // Both T will go through same code path - var declaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; - displayParts.push(ts.keywordPart(130 /* TypeKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).parent; + displayParts.push(ts.keywordPart(132 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -45203,11 +46057,11 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 245 /* EnumMember */) { + if (declaration.kind === 247 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55 /* EqualsToken */)); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } @@ -45215,17 +46069,17 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(87 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(89 /* ImportKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 219 /* ImportEqualsDeclaration */) { + if (declaration.kind === 221 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55 /* EqualsToken */)); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(125 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(127 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); @@ -45234,7 +46088,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55 /* EqualsToken */)); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -45251,7 +46105,7 @@ var ts; if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 /* Variable */ || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(53 /* ColonToken */)); + displayParts.push(ts.punctuationPart(54 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -45351,11 +46205,11 @@ var ts; if (!symbol) { // Try getting just type at this position and show switch (node.kind) { - case 67 /* Identifier */: - case 164 /* PropertyAccessExpression */: - case 133 /* QualifiedName */: - case 95 /* ThisKeyword */: - case 93 /* SuperKeyword */: + case 69 /* Identifier */: + case 166 /* PropertyAccessExpression */: + case 135 /* QualifiedName */: + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -45408,7 +46262,7 @@ var ts; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (isNewExpressionTarget(location) || location.kind === 119 /* ConstructorKeyword */) { + if (isNewExpressionTarget(location) || location.kind === 121 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { // Find the first class-like declaration and try to get the construct signature. for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { @@ -45433,8 +46287,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 142 /* Constructor */) || - (!selectConstructors && (d.kind === 211 /* FunctionDeclaration */ || d.kind === 141 /* MethodDeclaration */ || d.kind === 140 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 144 /* Constructor */) || + (!selectConstructors && (d.kind === 213 /* FunctionDeclaration */ || d.kind === 143 /* MethodDeclaration */ || d.kind === 142 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -45494,7 +46348,7 @@ var ts; // to jump to the implementation directly. if (symbol.flags & 8388608 /* Alias */) { var declaration = symbol.declarations[0]; - if (node.kind === 67 /* Identifier */ && node.parent === declaration) { + if (node.kind === 69 /* Identifier */ && node.parent === declaration) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -45503,7 +46357,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 244 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 246 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -45577,9 +46431,9 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 67 /* Identifier */ || - node.kind === 95 /* ThisKeyword */ || - node.kind === 93 /* SuperKeyword */ || + if (node.kind === 69 /* Identifier */ || + node.kind === 97 /* ThisKeyword */ || + node.kind === 95 /* SuperKeyword */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false); @@ -45630,77 +46484,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 86 /* IfKeyword */: - case 78 /* ElseKeyword */: - if (hasKind(node.parent, 194 /* IfStatement */)) { + case 88 /* IfKeyword */: + case 80 /* ElseKeyword */: + if (hasKind(node.parent, 196 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; - case 92 /* ReturnKeyword */: - if (hasKind(node.parent, 202 /* ReturnStatement */)) { + case 94 /* ReturnKeyword */: + if (hasKind(node.parent, 204 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; - case 96 /* ThrowKeyword */: - if (hasKind(node.parent, 206 /* ThrowStatement */)) { + case 98 /* ThrowKeyword */: + if (hasKind(node.parent, 208 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; - case 70 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 207 /* TryStatement */)) { + case 72 /* CatchKeyword */: + if (hasKind(parent(parent(node)), 209 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 98 /* TryKeyword */: - case 83 /* FinallyKeyword */: - if (hasKind(parent(node), 207 /* TryStatement */)) { + case 100 /* TryKeyword */: + case 85 /* FinallyKeyword */: + if (hasKind(parent(node), 209 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 94 /* SwitchKeyword */: - if (hasKind(node.parent, 204 /* SwitchStatement */)) { + case 96 /* SwitchKeyword */: + if (hasKind(node.parent, 206 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 69 /* CaseKeyword */: - case 75 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 204 /* SwitchStatement */)) { + case 71 /* CaseKeyword */: + case 77 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 206 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 68 /* BreakKeyword */: - case 73 /* ContinueKeyword */: - if (hasKind(node.parent, 201 /* BreakStatement */) || hasKind(node.parent, 200 /* ContinueStatement */)) { + case 70 /* BreakKeyword */: + case 75 /* ContinueKeyword */: + if (hasKind(node.parent, 203 /* BreakStatement */) || hasKind(node.parent, 202 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 84 /* ForKeyword */: - if (hasKind(node.parent, 197 /* ForStatement */) || - hasKind(node.parent, 198 /* ForInStatement */) || - hasKind(node.parent, 199 /* ForOfStatement */)) { + case 86 /* ForKeyword */: + if (hasKind(node.parent, 199 /* ForStatement */) || + hasKind(node.parent, 200 /* ForInStatement */) || + hasKind(node.parent, 201 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 102 /* WhileKeyword */: - case 77 /* DoKeyword */: - if (hasKind(node.parent, 196 /* WhileStatement */) || hasKind(node.parent, 195 /* DoStatement */)) { + case 104 /* WhileKeyword */: + case 79 /* DoKeyword */: + if (hasKind(node.parent, 198 /* WhileStatement */) || hasKind(node.parent, 197 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 119 /* ConstructorKeyword */: - if (hasKind(node.parent, 142 /* Constructor */)) { + case 121 /* ConstructorKeyword */: + if (hasKind(node.parent, 144 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; - case 121 /* GetKeyword */: - case 127 /* SetKeyword */: - if (hasKind(node.parent, 143 /* GetAccessor */) || hasKind(node.parent, 144 /* SetAccessor */)) { + case 123 /* GetKeyword */: + case 129 /* SetKeyword */: + if (hasKind(node.parent, 145 /* GetAccessor */) || hasKind(node.parent, 146 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 191 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 193 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -45716,10 +46570,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 206 /* ThrowStatement */) { + if (node.kind === 208 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 207 /* TryStatement */) { + else if (node.kind === 209 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -45748,12 +46602,12 @@ var ts; var child = throwStatement; while (child.parent) { var parent_12 = child.parent; - if (ts.isFunctionBlock(parent_12) || parent_12.kind === 246 /* SourceFile */) { + if (ts.isFunctionBlock(parent_12) || parent_12.kind === 248 /* SourceFile */) { return parent_12; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_12.kind === 207 /* TryStatement */) { + if (parent_12.kind === 209 /* TryStatement */) { var tryStatement = parent_12; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; @@ -45768,7 +46622,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 201 /* BreakStatement */ || node.kind === 200 /* ContinueStatement */) { + if (node.kind === 203 /* BreakStatement */ || node.kind === 202 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -45784,16 +46638,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 204 /* SwitchStatement */: - if (statement.kind === 200 /* ContinueStatement */) { + case 206 /* SwitchStatement */: + if (statement.kind === 202 /* ContinueStatement */) { continue; } // Fall through. - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 196 /* WhileStatement */: - case 195 /* DoStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 198 /* WhileStatement */: + case 197 /* DoStatement */: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -45812,24 +46666,24 @@ var ts; var container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 212 /* ClassDeclaration */ || - container.kind === 184 /* ClassExpression */ || - (declaration.kind === 136 /* Parameter */ && hasKind(container, 142 /* Constructor */)))) { + if (!(container.kind === 214 /* ClassDeclaration */ || + container.kind === 186 /* ClassExpression */ || + (declaration.kind === 138 /* Parameter */ && hasKind(container, 144 /* Constructor */)))) { return undefined; } } - else if (modifier === 111 /* StaticKeyword */) { - if (!(container.kind === 212 /* ClassDeclaration */ || container.kind === 184 /* ClassExpression */)) { + else if (modifier === 113 /* StaticKeyword */) { + if (!(container.kind === 214 /* ClassDeclaration */ || container.kind === 186 /* ClassExpression */)) { return undefined; } } - else if (modifier === 80 /* ExportKeyword */ || modifier === 120 /* DeclareKeyword */) { - if (!(container.kind === 217 /* ModuleBlock */ || container.kind === 246 /* SourceFile */)) { + else if (modifier === 82 /* ExportKeyword */ || modifier === 122 /* DeclareKeyword */) { + if (!(container.kind === 219 /* ModuleBlock */ || container.kind === 248 /* SourceFile */)) { return undefined; } } - else if (modifier === 113 /* AbstractKeyword */) { - if (!(container.kind === 212 /* ClassDeclaration */ || declaration.kind === 212 /* ClassDeclaration */)) { + else if (modifier === 115 /* AbstractKeyword */) { + if (!(container.kind === 214 /* ClassDeclaration */ || declaration.kind === 214 /* ClassDeclaration */)) { return undefined; } } @@ -45841,8 +46695,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 217 /* ModuleBlock */: - case 246 /* SourceFile */: + case 219 /* ModuleBlock */: + case 248 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 256 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -45851,17 +46705,17 @@ var ts; nodes = container.statements; } break; - case 142 /* Constructor */: + case 144 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. if (modifierFlag & 112 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 142 /* Constructor */ && member; + return member.kind === 144 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -45882,19 +46736,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 110 /* PublicKeyword */: + case 112 /* PublicKeyword */: return 16 /* Public */; - case 108 /* PrivateKeyword */: + case 110 /* PrivateKeyword */: return 32 /* Private */; - case 109 /* ProtectedKeyword */: + case 111 /* ProtectedKeyword */: return 64 /* Protected */; - case 111 /* StaticKeyword */: + case 113 /* StaticKeyword */: return 128 /* Static */; - case 80 /* ExportKeyword */: + case 82 /* ExportKeyword */: return 1 /* Export */; - case 120 /* DeclareKeyword */: + case 122 /* DeclareKeyword */: return 2 /* Ambient */; - case 113 /* AbstractKeyword */: + case 115 /* AbstractKeyword */: return 256 /* Abstract */; default: ts.Debug.fail(); @@ -45914,13 +46768,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 143 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 144 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 145 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 146 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 121 /* GetKeyword */, 127 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 123 /* GetKeyword */, 129 /* SetKeyword */); }); } } } @@ -45929,19 +46783,19 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 119 /* ConstructorKeyword */); + return pushKeywordIf(keywords, token, 121 /* ConstructorKeyword */); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 84 /* ForKeyword */, 102 /* WhileKeyword */, 77 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86 /* ForKeyword */, 104 /* WhileKeyword */, 79 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 195 /* DoStatement */) { + if (loopNode.kind === 197 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 102 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 104 /* WhileKeyword */)) { break; } } @@ -45950,7 +46804,7 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */, 73 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */, 75 /* ContinueKeyword */); } }); return ts.map(keywords, getHighlightSpanForNode); @@ -45959,13 +46813,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 204 /* SwitchStatement */: + case 206 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -45973,14 +46827,14 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 94 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 96 /* SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 69 /* CaseKeyword */, 75 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 71 /* CaseKeyword */, 77 /* DefaultKeyword */); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */); } }); }); @@ -45988,13 +46842,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 98 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 100 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 70 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 83 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 85 /* FinallyKeyword */); } return ts.map(keywords, getHighlightSpanForNode); } @@ -46005,13 +46859,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); }); } return ts.map(keywords, getHighlightSpanForNode); @@ -46019,36 +46873,36 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 190 /* Block */))) { + if (!(func && hasKind(func.body, 192 /* Block */))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 194 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 196 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 86 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 88 /* IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 78 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 80 /* ElseKeyword */)) { break; } } - if (!hasKind(ifStatement.elseStatement, 194 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 196 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -46057,7 +46911,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 78 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 80 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombindElseAndIf = true; @@ -46139,7 +46993,7 @@ var ts; if (!node) { return undefined; } - if (node.kind !== 67 /* Identifier */ && + if (node.kind !== 69 /* Identifier */ && // TODO (drosen): This should be enabled in a later release - currently breaks rename. //node.kind !== SyntaxKind.ThisKeyword && //node.kind !== SyntaxKind.SuperKeyword && @@ -46147,7 +47001,7 @@ var ts; !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */); + ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */); return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { @@ -46165,10 +47019,10 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 95 /* ThisKeyword */) { + if (node.kind === 97 /* ThisKeyword */) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 93 /* SuperKeyword */) { + if (node.kind === 95 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } var symbol = typeChecker.getSymbolAtLocation(node); @@ -46228,7 +47082,7 @@ var ts; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 228 /* ExportSpecifier */; + return declaration.kind === 226 /* ImportSpecifier */ || declaration.kind === 230 /* ExportSpecifier */; }); } function getInternedName(symbol, location, declarations) { @@ -46255,14 +47109,14 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 171 /* FunctionExpression */ || valueDeclaration.kind === 184 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 173 /* FunctionExpression */ || valueDeclaration.kind === 186 /* ClassExpression */)) { return valueDeclaration; } // If this is private property or method, the scope is the containing class if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 212 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 214 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -46288,7 +47142,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 246 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 248 /* SourceFile */ && !ts.isExternalModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -46359,7 +47213,7 @@ var ts; if (node) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: return node.getWidth() === searchSymbolName.length; case 9 /* StringLiteral */: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || @@ -46461,13 +47315,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -46480,7 +47334,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 93 /* SuperKeyword */) { + if (!node || node.kind !== 95 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*includeFunctions*/ false); @@ -46499,27 +47353,27 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 246 /* SourceFile */: + case 248 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. @@ -46528,7 +47382,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 246 /* SourceFile */) { + if (searchSpaceNode.kind === 248 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -46554,33 +47408,33 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 95 /* ThisKeyword */) { + if (!node || node.kind !== 97 /* ThisKeyword */) { return; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 171 /* FunctionExpression */: - case 211 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 184 /* ClassExpression */: - case 212 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 246 /* SourceFile */: - if (container.kind === 246 /* SourceFile */ && !ts.isExternalModule(container)) { + case 248 /* SourceFile */: + if (container.kind === 248 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -46634,11 +47488,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 212 /* ClassDeclaration */) { + if (declaration.kind === 214 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 213 /* InterfaceDeclaration */) { + else if (declaration.kind === 215 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -46699,19 +47553,19 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_33 = node.text; + var name_34 = node.text; if (contextualType) { if (contextualType.flags & 16384 /* Union */) { // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) // if not, search the constituent types for the property - var unionProperty = contextualType.getProperty(name_33); + var unionProperty = contextualType.getProperty(name_34); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_33); + var symbol = t.getProperty(name_34); if (symbol) { result_4.push(symbol); } @@ -46720,7 +47574,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_33); + var symbol_1 = contextualType.getProperty(name_34); if (symbol_1) { return [symbol_1]; } @@ -46773,17 +47627,17 @@ var ts; } /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccess(node) { - if (node.kind === 67 /* Identifier */ && ts.isDeclarationName(node)) { + if (node.kind === 69 /* Identifier */ && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 178 /* PostfixUnaryExpression */ || parent.kind === 177 /* PrefixUnaryExpression */) { + if (parent.kind === 180 /* PostfixUnaryExpression */ || parent.kind === 179 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 179 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 181 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; - return 55 /* FirstAssignment */ <= operator && operator <= 66 /* LastAssignment */; + return 56 /* FirstAssignment */ <= operator && operator <= 68 /* LastAssignment */; } } return false; @@ -46815,33 +47669,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 136 /* Parameter */: - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 243 /* PropertyAssignment */: - case 244 /* ShorthandPropertyAssignment */: - case 245 /* EnumMember */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 242 /* CatchClause */: + case 138 /* Parameter */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 245 /* PropertyAssignment */: + case 246 /* ShorthandPropertyAssignment */: + case 247 /* EnumMember */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 244 /* CatchClause */: return 1 /* Value */; - case 135 /* TypeParameter */: - case 213 /* InterfaceDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 153 /* TypeLiteral */: + case 137 /* TypeParameter */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 155 /* TypeLiteral */: return 2 /* Type */; - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: if (node.name.kind === 9 /* StringLiteral */) { return 4 /* Namespace */ | 1 /* Value */; } @@ -46851,15 +47705,15 @@ var ts; else { return 4 /* Namespace */; } - case 223 /* NamedImports */: - case 224 /* ImportSpecifier */: - case 219 /* ImportEqualsDeclaration */: - case 220 /* ImportDeclaration */: - case 225 /* ExportAssignment */: - case 226 /* ExportDeclaration */: + case 225 /* NamedImports */: + case 226 /* ImportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 222 /* ImportDeclaration */: + case 227 /* ExportAssignment */: + case 228 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 246 /* SourceFile */: + case 248 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -46869,8 +47723,9 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 149 /* TypeReference */ || - (node.parent.kind === 186 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); + return node.parent.kind === 151 /* TypeReference */ || + (node.parent.kind === 188 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + node.kind === 97 /* ThisKeyword */ && !ts.isExpression(node); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -46878,50 +47733,50 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 164 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 164 /* PropertyAccessExpression */) { + if (root.parent.kind === 166 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 166 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 186 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 241 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 188 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 243 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 212 /* ClassDeclaration */ && root.parent.parent.token === 104 /* ImplementsKeyword */) || - (decl.kind === 213 /* InterfaceDeclaration */ && root.parent.parent.token === 81 /* ExtendsKeyword */); + return (decl.kind === 214 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) || + (decl.kind === 215 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 133 /* QualifiedName */) { - while (root.parent && root.parent.kind === 133 /* QualifiedName */) { + if (root.parent.kind === 135 /* QualifiedName */) { + while (root.parent && root.parent.kind === 135 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 149 /* TypeReference */ && !isLastClause; + return root.parent.kind === 151 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 133 /* QualifiedName */) { + while (node.parent.kind === 135 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 67 /* Identifier */); + ts.Debug.assert(node.kind === 69 /* Identifier */); // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 133 /* QualifiedName */ && + if (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 219 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 221 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 225 /* ExportAssignment */) { + if (node.parent.kind === 227 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -46961,15 +47816,15 @@ var ts; return; } switch (node.kind) { - case 164 /* PropertyAccessExpression */: - case 133 /* QualifiedName */: + case 166 /* PropertyAccessExpression */: + case 135 /* QualifiedName */: case 9 /* StringLiteral */: - case 82 /* FalseKeyword */: - case 97 /* TrueKeyword */: - case 91 /* NullKeyword */: - case 93 /* SuperKeyword */: - case 95 /* ThisKeyword */: - case 67 /* Identifier */: + case 84 /* FalseKeyword */: + case 99 /* TrueKeyword */: + case 93 /* NullKeyword */: + case 95 /* SuperKeyword */: + case 97 /* ThisKeyword */: + case 69 /* Identifier */: break; // Cant create the text span default: @@ -46985,7 +47840,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 216 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 218 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -47026,10 +47881,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 216 /* ModuleDeclaration */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 211 /* FunctionDeclaration */: + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -47083,7 +47938,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 216 /* ModuleDeclaration */ && + return declaration.kind === 218 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -47093,7 +47948,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(kind); - if (kind === 67 /* Identifier */ && !ts.nodeIsMissing(node)) { + if (kind === 69 /* Identifier */ && !ts.nodeIsMissing(node)) { var identifier = node; // Only bother calling into the typechecker if this is an identifier that // could possibly resolve to a type name. This makes classification run @@ -47238,16 +48093,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 265 /* JSDocParameterTag */: + case 267 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 268 /* JSDocTemplateTag */: + case 270 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 267 /* JSDocTypeTag */: + case 269 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 266 /* JSDocReturnTag */: + case 268 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -47336,18 +48191,18 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 55 /* EqualsToken */) { + if (tokenKind === 56 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 209 /* VariableDeclaration */ || - token.parent.kind === 139 /* PropertyDeclaration */ || - token.parent.kind === 136 /* Parameter */) { + if (token.parent.kind === 211 /* VariableDeclaration */ || + token.parent.kind === 141 /* PropertyDeclaration */ || + token.parent.kind === 138 /* Parameter */) { return 5 /* operator */; } } - if (token.parent.kind === 179 /* BinaryExpression */ || - token.parent.kind === 177 /* PrefixUnaryExpression */ || - token.parent.kind === 178 /* PostfixUnaryExpression */ || - token.parent.kind === 180 /* ConditionalExpression */) { + if (token.parent.kind === 181 /* BinaryExpression */ || + token.parent.kind === 179 /* PrefixUnaryExpression */ || + token.parent.kind === 180 /* PostfixUnaryExpression */ || + token.parent.kind === 182 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -47367,35 +48222,35 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 67 /* Identifier */) { + else if (tokenKind === 69 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 135 /* TypeParameter */: + case 137 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 136 /* Parameter */: + case 138 /* Parameter */: if (token.parent.name === token) { return 17 /* parameterName */; } @@ -47507,8 +48362,12 @@ var ts; * Checks if position points to a valid position to add JSDoc comments, and if so, * returns the appropriate template. Otherwise returns an empty string. * Valid positions are - * - outside of comments, statements, and expressions, and - * - preceding a function declaration. + * - outside of comments, statements, and expressions, and + * - preceding a: + * - function/constructor/method declaration + * - class declarations + * - variable statements + * - namespace declarations * * Hosts should ideally check that: * - The line is all whitespace up to 'position' before performing the insertion. @@ -47532,23 +48391,48 @@ var ts; return undefined; } // TODO: add support for: - // - methods - // - constructors - // - class decls - var containingFunction = ts.getAncestor(tokenAtPos, 211 /* FunctionDeclaration */); - if (!containingFunction || containingFunction.getStart() < position) { + // - enums/enum members + // - interfaces + // - property declarations + // - potentially property assignments + var commentOwner; + findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { + switch (commentOwner.kind) { + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 144 /* Constructor */: + case 214 /* ClassDeclaration */: + case 193 /* VariableStatement */: + break findOwner; + case 248 /* SourceFile */: + return undefined; + case 218 /* ModuleDeclaration */: + // If in walking up the tree, we hit a a nested namespace declaration, + // then we must be somewhere within a dotted namespace name; however we don't + // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. + if (commentOwner.parent.kind === 218 /* ModuleDeclaration */) { + return undefined; + } + break findOwner; + } + } + if (!commentOwner || commentOwner.getStart() < position) { return undefined; } - var parameters = containingFunction.parameters; + var parameters = getParametersForJsDocOwningNode(commentOwner); var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); // TODO: call a helper method instead once PR #4133 gets merged in. var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; - var docParams = parameters.reduce(function (prev, cur, index) { - return prev + - indentationStr + " * @param " + (cur.name.kind === 67 /* Identifier */ ? cur.name.text : "param" + index) + newLine; - }, ""); + var docParams = ""; + for (var i = 0, numParams = parameters.length; i < numParams; i++) { + var currentName = parameters[i].name; + var paramName = currentName.kind === 69 /* Identifier */ ? + currentName.text : + "param" + i; + docParams += indentationStr + " * @param " + paramName + newLine; + } // A doc comment consists of the following // * The opening comment line // * the first line (without a param) for the object's untagged info (this is also where the caret ends up) @@ -47564,6 +48448,46 @@ var ts; (tokenStart === position ? newLine + indentationStr : ""); return { newText: result, caretOffset: preamble.length }; } + function getParametersForJsDocOwningNode(commentOwner) { + if (ts.isFunctionLike(commentOwner)) { + return commentOwner.parameters; + } + if (commentOwner.kind === 193 /* VariableStatement */) { + var varStatement = commentOwner; + var varDeclarations = varStatement.declarationList.declarations; + if (varDeclarations.length === 1 && varDeclarations[0].initializer) { + return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); + } + } + return emptyArray; + } + /** + * Digs into an an initializer or RHS operand of an assignment operation + * to get the parameters of an apt signature corresponding to a + * function expression or a class expression. + * + * @param rightHandSide the expression which may contain an appropriate set of parameters + * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. + */ + function getParametersFromRightHandSideOfAssignment(rightHandSide) { + while (rightHandSide.kind === 172 /* ParenthesizedExpression */) { + rightHandSide = rightHandSide.expression; + } + switch (rightHandSide.kind) { + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + return rightHandSide.parameters; + case 186 /* ClassExpression */: + for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.kind === 144 /* Constructor */) { + return member.parameters; + } + } + break; + } + return emptyArray; + } function getTodoComments(fileName, descriptors) { // Note: while getting todo comments seems like a syntactic operation, we actually // treat it as a semantic operation here. This is because we expect our host to call @@ -47694,7 +48618,7 @@ var ts; var typeChecker = program.getTypeChecker(); var node = ts.getTouchingWord(sourceFile, position); // Can only rename an identifier. - if (node && node.kind === 67 /* Identifier */) { + if (node && node.kind === 69 /* Identifier */) { var symbol = typeChecker.getSymbolAtLocation(node); // Only allow a symbol to be renamed if it actually has at least one declaration. if (symbol) { @@ -47795,7 +48719,7 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: nameTable[node.text] = node.text; break; case 9 /* StringLiteral */: @@ -47805,7 +48729,7 @@ var ts; // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 230 /* ExternalModuleReference */ || + node.parent.kind === 232 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -47818,7 +48742,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 165 /* ElementAccessExpression */ && + node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier @@ -47829,18 +48753,18 @@ var ts; /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = []; - noRegexTable[67 /* Identifier */] = true; + noRegexTable[69 /* Identifier */] = true; noRegexTable[9 /* StringLiteral */] = true; noRegexTable[8 /* NumericLiteral */] = true; noRegexTable[10 /* RegularExpressionLiteral */] = true; - noRegexTable[95 /* ThisKeyword */] = true; - noRegexTable[40 /* PlusPlusToken */] = true; - noRegexTable[41 /* MinusMinusToken */] = true; + noRegexTable[97 /* ThisKeyword */] = true; + noRegexTable[41 /* PlusPlusToken */] = true; + noRegexTable[42 /* MinusMinusToken */] = true; noRegexTable[18 /* CloseParenToken */] = true; noRegexTable[20 /* CloseBracketToken */] = true; noRegexTable[16 /* CloseBraceToken */] = true; - noRegexTable[97 /* TrueKeyword */] = true; - noRegexTable[82 /* FalseKeyword */] = true; + noRegexTable[99 /* TrueKeyword */] = true; + noRegexTable[84 /* FalseKeyword */] = true; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -47865,10 +48789,10 @@ var ts; /** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */ function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 121 /* GetKeyword */ || - keyword2 === 127 /* SetKeyword */ || - keyword2 === 119 /* ConstructorKeyword */ || - keyword2 === 111 /* StaticKeyword */) { + if (keyword2 === 123 /* GetKeyword */ || + keyword2 === 129 /* SetKeyword */ || + keyword2 === 121 /* ConstructorKeyword */ || + keyword2 === 113 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". // These are all legal. return true; @@ -47998,22 +48922,22 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { + if ((token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { if (scanner.reScanSlashToken() === 10 /* RegularExpressionLiteral */) { token = 10 /* RegularExpressionLiteral */; } } else if (lastNonTriviaToken === 21 /* DotToken */ && isKeyword(token)) { - token = 67 /* Identifier */; + token = 69 /* Identifier */; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 67 /* Identifier */; + token = 69 /* Identifier */; } - else if (lastNonTriviaToken === 67 /* Identifier */ && + else if (lastNonTriviaToken === 69 /* Identifier */ && token === 25 /* LessThanToken */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. @@ -48024,16 +48948,16 @@ var ts; // generic entity is complete. angleBracketStack--; } - else if (token === 115 /* AnyKeyword */ || - token === 128 /* StringKeyword */ || - token === 126 /* NumberKeyword */ || - token === 118 /* BooleanKeyword */ || - token === 129 /* SymbolKeyword */) { + else if (token === 117 /* AnyKeyword */ || + token === 130 /* StringKeyword */ || + token === 128 /* NumberKeyword */ || + token === 120 /* BooleanKeyword */ || + token === 131 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 67 /* Identifier */; + token = 69 /* Identifier */; } } else if (token === 12 /* TemplateHead */) { @@ -48145,40 +49069,41 @@ var ts; function isBinaryExpressionOperatorToken(token) { switch (token) { case 37 /* AsteriskToken */: - case 38 /* SlashToken */: - case 39 /* PercentToken */: + case 39 /* SlashToken */: + case 40 /* PercentToken */: case 35 /* PlusToken */: case 36 /* MinusToken */: - case 42 /* LessThanLessThanToken */: - case 43 /* GreaterThanGreaterThanToken */: - case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 43 /* LessThanLessThanToken */: + case 44 /* GreaterThanGreaterThanToken */: + case 45 /* GreaterThanGreaterThanGreaterThanToken */: case 25 /* LessThanToken */: case 27 /* GreaterThanToken */: case 28 /* LessThanEqualsToken */: case 29 /* GreaterThanEqualsToken */: - case 89 /* InstanceOfKeyword */: - case 88 /* InKeyword */: + case 91 /* InstanceOfKeyword */: + case 90 /* InKeyword */: + case 116 /* AsKeyword */: case 30 /* EqualsEqualsToken */: case 31 /* ExclamationEqualsToken */: case 32 /* EqualsEqualsEqualsToken */: case 33 /* ExclamationEqualsEqualsToken */: - case 45 /* AmpersandToken */: - case 47 /* CaretToken */: - case 46 /* BarToken */: - case 50 /* AmpersandAmpersandToken */: - case 51 /* BarBarToken */: - case 65 /* BarEqualsToken */: - case 64 /* AmpersandEqualsToken */: - case 66 /* CaretEqualsToken */: - case 61 /* LessThanLessThanEqualsToken */: - case 62 /* GreaterThanGreaterThanEqualsToken */: - case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 56 /* PlusEqualsToken */: - case 57 /* MinusEqualsToken */: - case 58 /* AsteriskEqualsToken */: - case 59 /* SlashEqualsToken */: - case 60 /* PercentEqualsToken */: - case 55 /* EqualsToken */: + case 46 /* AmpersandToken */: + case 48 /* CaretToken */: + case 47 /* BarToken */: + case 51 /* AmpersandAmpersandToken */: + case 52 /* BarBarToken */: + case 67 /* BarEqualsToken */: + case 66 /* AmpersandEqualsToken */: + case 68 /* CaretEqualsToken */: + case 63 /* LessThanLessThanEqualsToken */: + case 64 /* GreaterThanGreaterThanEqualsToken */: + case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 57 /* PlusEqualsToken */: + case 58 /* MinusEqualsToken */: + case 59 /* AsteriskEqualsToken */: + case 61 /* SlashEqualsToken */: + case 62 /* PercentEqualsToken */: + case 56 /* EqualsToken */: case 24 /* CommaToken */: return true; default: @@ -48189,17 +49114,17 @@ var ts; switch (token) { case 35 /* PlusToken */: case 36 /* MinusToken */: - case 49 /* TildeToken */: - case 48 /* ExclamationToken */: - case 40 /* PlusPlusToken */: - case 41 /* MinusMinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: + case 41 /* PlusPlusToken */: + case 42 /* MinusMinusToken */: return true; default: return false; } } function isKeyword(token) { - return token >= 68 /* FirstKeyword */ && token <= 132 /* LastKeyword */; + return token >= 70 /* FirstKeyword */ && token <= 134 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -48208,7 +49133,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 15 /* FirstPunctuation */ && token <= 66 /* LastPunctuation */) { + else if (token >= 15 /* FirstPunctuation */ && token <= 68 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -48225,7 +49150,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 67 /* Identifier */: + case 69 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -48257,7 +49182,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 246 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + var proto = kind === 248 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = -1; proto.end = -1; @@ -48327,125 +49252,125 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 195 /* DoStatement */) { + if (node.parent.kind === 197 /* DoStatement */) { // Set span as if on while keyword return spanInPreviousNode(node); } - if (node.parent.kind === 197 /* ForStatement */) { + if (node.parent.kind === 199 /* ForStatement */) { // For now lets set the span on this expression, fix it later return textSpan(node); } - if (node.parent.kind === 179 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) { + if (node.parent.kind === 181 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) { // if this is comma expression, the breakpoint is possible in this expression return textSpan(node); } - if (node.parent.kind === 172 /* ArrowFunction */ && node.parent.body === node) { + if (node.parent.kind === 174 /* ArrowFunction */ && node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); } } switch (node.kind) { - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 209 /* VariableDeclaration */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 211 /* VariableDeclaration */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return spanInVariableDeclaration(node); - case 136 /* Parameter */: + case 138 /* Parameter */: return spanInParameterDeclaration(node); - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 142 /* Constructor */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 190 /* Block */: + case 192 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 217 /* ModuleBlock */: + case 219 /* ModuleBlock */: return spanInBlock(node); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return spanInBlock(node.block); - case 193 /* ExpressionStatement */: + case 195 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 202 /* ReturnStatement */: + case 204 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 196 /* WhileStatement */: + case 198 /* WhileStatement */: // Span on while(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 195 /* DoStatement */: + case 197 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 208 /* DebuggerStatement */: + case 210 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 194 /* IfStatement */: + case 196 /* IfStatement */: // set on if(..) span return textSpan(node, ts.findNextToken(node.expression, node)); - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 201 /* BreakStatement */: - case 200 /* ContinueStatement */: + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 197 /* ForStatement */: + case 199 /* ForStatement */: return spanInForStatement(node); - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: // span on for (a in ...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 204 /* SwitchStatement */: + case 206 /* SwitchStatement */: // span on switch(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 239 /* CaseClause */: - case 240 /* DefaultClause */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 207 /* TryStatement */: + case 209 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 206 /* ThrowStatement */: + case 208 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: - case 245 /* EnumMember */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: // span on complete node return textSpan(node); - case 203 /* WithStatement */: + case 205 /* WithStatement */: // span in statement return spanInNode(node.statement); // No breakpoint in interface, type alias - case 213 /* InterfaceDeclaration */: - case 214 /* TypeAliasDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: return undefined; // Tokens: case 23 /* SemicolonToken */: @@ -48461,25 +49386,25 @@ var ts; return spanInOpenParenToken(node); case 18 /* CloseParenToken */: return spanInCloseParenToken(node); - case 53 /* ColonToken */: + case 54 /* ColonToken */: return spanInColonToken(node); case 27 /* GreaterThanToken */: case 25 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 102 /* WhileKeyword */: + case 104 /* WhileKeyword */: return spanInWhileKeyword(node); - case 78 /* ElseKeyword */: - case 70 /* CatchKeyword */: - case 83 /* FinallyKeyword */: + case 80 /* ElseKeyword */: + case 72 /* CatchKeyword */: + case 85 /* FinallyKeyword */: return spanInNextNode(node); default: // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 243 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 245 /* PropertyAssignment */ && node.parent.name === node) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 169 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 171 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNode(node.parent.expression); } // return type of function go to previous token @@ -48492,12 +49417,12 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 198 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */) { + if (variableDeclaration.parent.parent.kind === 200 /* ForInStatement */ || + variableDeclaration.parent.parent.kind === 201 /* ForOfStatement */) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 191 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 197 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 193 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 199 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -48551,7 +49476,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1 /* Export */) || - (functionDeclaration.parent.kind === 212 /* ClassDeclaration */ && functionDeclaration.kind !== 142 /* Constructor */); + (functionDeclaration.parent.kind === 214 /* ClassDeclaration */ && functionDeclaration.kind !== 144 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -48574,18 +49499,18 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 196 /* WhileStatement */: - case 194 /* IfStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 198 /* WhileStatement */: + case 196 /* IfStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 197 /* ForStatement */: + case 199 /* ForStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement @@ -48593,7 +49518,7 @@ var ts; } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 210 /* VariableDeclarationList */) { + if (forStatement.initializer.kind === 212 /* VariableDeclarationList */) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -48613,13 +49538,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 218 /* CaseBlock */: + case 220 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -48627,25 +49552,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 217 /* ModuleBlock */: + case 219 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 215 /* EnumDeclaration */: - case 212 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 214 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 190 /* Block */: + case 192 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 242 /* CatchClause */: + case 244 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 218 /* CaseBlock */: + case 220 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -48659,7 +49584,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 195 /* DoStatement */) { + if (node.parent.kind === 197 /* DoStatement */) { // Go to while keyword and do action instead return spanInPreviousNode(node); } @@ -48669,17 +49594,17 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 171 /* FunctionExpression */: - case 211 /* FunctionDeclaration */: - case 172 /* ArrowFunction */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 142 /* Constructor */: - case 196 /* WhileStatement */: - case 195 /* DoStatement */: - case 197 /* ForStatement */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: + case 198 /* WhileStatement */: + case 197 /* DoStatement */: + case 199 /* ForStatement */: return spanInPreviousNode(node); // Default to parent node default: @@ -48690,19 +49615,19 @@ var ts; } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 243 /* PropertyAssignment */) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 245 /* PropertyAssignment */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 169 /* TypeAssertionExpression */) { + if (node.parent.kind === 171 /* TypeAssertionExpression */) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 195 /* DoStatement */) { + if (node.parent.kind === 197 /* DoStatement */) { // Set span on while expression return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } @@ -49339,7 +50264,8 @@ var ts; }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { - var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); + // for now treat files as JavaScript + var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), /* readImportFiles */ true, /* detectJavaScriptImports */ true); var convertResult = { referencedFiles: [], importedFiles: [], From abf270a9b4498e1f7d41fad503e3f606d043ff12 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 22 Oct 2015 14:12:57 -0700 Subject: [PATCH 06/10] do not look into nested es6 exports / imports when collecting external modules --- src/compiler/program.ts | 87 ++++++++++++++++++--------------------- src/compiler/utilities.ts | 2 +- 2 files changed, 42 insertions(+), 47 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 13d939c8ac73a..583db7850b9f0 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -689,61 +689,56 @@ namespace ts { let imports: LiteralExpression[]; for (let node of file.statements) { - collect(node, /* allowRelativeModuleNames */ true); + collect(node, /* allowRelativeModuleNames */ true, /* collectOnlyRequireCalls */ false); } file.imports = imports || emptyArray; - function collect(node: Node, allowRelativeModuleNames: boolean): void { - switch (node.kind) { - case SyntaxKind.ImportDeclaration: - case SyntaxKind.ImportEqualsDeclaration: - case SyntaxKind.ExportDeclaration: - let moduleNameExpr = getExternalModuleName(node); - if (!moduleNameExpr || moduleNameExpr.kind !== SyntaxKind.StringLiteral) { - break; - } - if (!(moduleNameExpr).text) { - break; - } + return; - if (allowRelativeModuleNames || !isExternalModuleNameRelative((moduleNameExpr).text)) { - (imports || (imports = [])).push(moduleNameExpr); - } - break; - case SyntaxKind.CallExpression: - if (isJavaScriptFile && isRequireCall(node)) { - - let jsImports = (node).arguments; - if (jsImports) { - imports = (imports || []); - for (var i = 0; i < jsImports.length; i++) { - if (jsImports[i].kind === SyntaxKind.StringLiteral) { - imports.push(jsImports[i]); - } - } + function collect(node: Node, allowRelativeModuleNames: boolean, collectOnlyRequireCalls: boolean): void { + if (!collectOnlyRequireCalls) { + switch (node.kind) { + case SyntaxKind.ImportDeclaration: + case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.ExportDeclaration: + let moduleNameExpr = getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== SyntaxKind.StringLiteral) { + break; } - } - break; - case SyntaxKind.ModuleDeclaration: - if ((node).name.kind === SyntaxKind.StringLiteral && (node.flags & NodeFlags.Ambient || isDeclarationFile(file))) { - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An AmbientExternalModuleDeclaration declares an external module. - // This type of declaration is permitted only in the global module. - // The StringLiteral must specify a top - level external module name. - // Relative external module names are not permitted - forEachChild((node).body, node => { + if (!(moduleNameExpr).text) { + break; + } + + if (allowRelativeModuleNames || !isExternalModuleNameRelative((moduleNameExpr).text)) { + (imports || (imports = [])).push(moduleNameExpr); + } + break; + case SyntaxKind.ModuleDeclaration: + if ((node).name.kind === SyntaxKind.StringLiteral && (node.flags & NodeFlags.Ambient || isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules - // only through top - level external module names. Relative external module names are not permitted. - collect(node, /* allowRelativeModuleNames */ false); - }); - } - break; + // An AmbientExternalModuleDeclaration declares an external module. + // This type of declaration is permitted only in the global module. + // The StringLiteral must specify a top - level external module name. + // Relative external module names are not permitted + forEachChild((node).body, node => { + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules + // only through top - level external module names. Relative external module names are not permitted. + collect(node, /* allowRelativeModuleNames */ false, collectOnlyRequireCalls); + }); + } + break; + } } - if (isSourceFileJavaScript(file)) { - forEachChild(node, node => collect(node, allowRelativeModuleNames)); + if (isJavaScriptFile) { + if (isRequireCall(node)) { + (imports || (imports = [])).push((node).arguments[0]); + } + else { + forEachChild(node, node => collect(node, allowRelativeModuleNames, /* collectOnlyRequireCalls */ true)); + } } } } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 9eff4370ec22a..5506a1d5e3dc8 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1045,7 +1045,7 @@ namespace ts { /** * Returns true if the node is a CallExpression to the identifier 'require' with - * exactly one argument. + * exactly one string literal argument. * This function does not test if the node is in a JavaScript file or not. */ export function isRequireCall(expression: Node): expression is CallExpression { From 91eb758d5958eb0c3f19e3d2ce1a6a5923019699 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 22 Oct 2015 15:39:01 -0700 Subject: [PATCH 07/10] CR feedback --- src/compiler/checker.ts | 12 ++---------- src/harness/harness.ts | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ac5056bf769a4..c407ca0c183a8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -160,8 +160,6 @@ namespace ts { let getGlobalPromiseConstructorLikeType: () => ObjectType; let getGlobalThenableType: () => ObjectType; - let cjsRequireType: Type; - let tupleTypes: Map = {}; let unionTypes: Map = {}; let intersectionTypes: Map = {}; @@ -4203,13 +4201,9 @@ namespace ts { * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type */ function getExportedTypeFromNamespace(namespace: string, name: string): Type { - let typeSymbol = getExportedSymbolFromNamespace(namespace, name); - return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); - } - - function getExportedSymbolFromNamespace(namespace: string, name: string): Symbol { let namespaceSymbol = getGlobalSymbol(namespace, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined); - return namespaceSymbol && getSymbol(namespaceSymbol.exports, name, SymbolFlags.Type | SymbolFlags.Value); + let typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, SymbolFlags.Type); + return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } function getGlobalESSymbolConstructorSymbol() { @@ -14938,8 +14932,6 @@ namespace ts { getGlobalPromiseConstructorLikeType = memoize(() => getGlobalType("PromiseConstructorLike")); getGlobalThenableType = memoize(createThenableType); - cjsRequireType = getExportedTypeFromNamespace("CommonJS", "Require"); - // If we're in ES6 mode, load the TemplateStringsArray. // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. if (languageVersion >= ScriptTarget.ES6) { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 91897493fd92f..a37b647a12490 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -211,7 +211,7 @@ namespace Utils { return isNodeOrArray(v) ? serializeNode(v) : v; }, " "); - function getKindName(k: number|string): string { + function getKindName(k: number | string): string { if (typeof k === "string") { return k; } From 7a940314753e96aefb1f00fe61440d06296f3899 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 6 Nov 2015 14:11:15 -0800 Subject: [PATCH 08/10] Rename `isTsx` for clarity --- src/compiler/parser.ts | 4 ++-- src/compiler/utilities.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index b477724475fb4..f81d4d5f86bd2 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -554,7 +554,7 @@ namespace ts { scanner.setText(sourceText); scanner.setOnError(scanError); scanner.setScriptTarget(languageVersion); - scanner.setLanguageVariant(isTsx(fileName) ? LanguageVariant.JSX : LanguageVariant.Standard); + scanner.setLanguageVariant(allowsJsxExpressions(fileName) ? LanguageVariant.JSX : LanguageVariant.Standard); } function clearState() { @@ -671,7 +671,7 @@ namespace ts { sourceFile.languageVersion = languageVersion; sourceFile.fileName = normalizePath(fileName); sourceFile.flags = fileExtensionIs(sourceFile.fileName, ".d.ts") ? NodeFlags.DeclarationFile : 0; - sourceFile.languageVariant = isTsx(sourceFile.fileName) ? LanguageVariant.JSX : LanguageVariant.Standard; + sourceFile.languageVariant = allowsJsxExpressions(sourceFile.fileName) ? LanguageVariant.JSX : LanguageVariant.Standard; return sourceFile; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 5506a1d5e3dc8..67f16cbfd0fa5 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2142,7 +2142,7 @@ namespace ts { return fileExtensionIs(fileName, ".js") || fileExtensionIs(fileName, ".jsx"); } - export function isTsx(fileName: string) { + export function allowsJsxExpressions(fileName: string) { return fileExtensionIs(fileName, ".tsx") || fileExtensionIs(fileName, ".jsx"); } From d880d4f4fb7c16bc5c6cb8fa38ace4371aa90850 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 6 Nov 2015 14:38:29 -0800 Subject: [PATCH 09/10] Don't look for .js files when resolving node modules --- src/compiler/program.ts | 2 +- tests/cases/unittests/moduleResolution.ts | 26 +---------------------- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 583db7850b9f0..62fb6850274ed 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -70,7 +70,7 @@ namespace ts { } function loadNodeModuleFromFile(candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string { - return forEach(supportedJsExtensions, tryLoad); + return forEach(supportedExtensions, tryLoad); function tryLoad(ext: string): string { let fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext; diff --git a/tests/cases/unittests/moduleResolution.ts b/tests/cases/unittests/moduleResolution.ts index 7e363d80d6d4d..2a5742a06ddd0 100644 --- a/tests/cases/unittests/moduleResolution.ts +++ b/tests/cases/unittests/moduleResolution.ts @@ -82,7 +82,7 @@ module ts { assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name); assert.equal(!!resolution.resolvedModule.isExternalLibraryImport, false); // expect three failed lookup location - attempt to load module as file with all supported extensions - assert.equal(resolution.failedLookupLocations.length, 5); + assert.equal(resolution.failedLookupLocations.length, 3); } it("module name as directory - load from typings", () => { @@ -103,8 +103,6 @@ module ts { "/a/b/foo.ts", "/a/b/foo.tsx", "/a/b/foo.d.ts", - "/a/b/foo.js", - "/a/b/foo.jsx", "/a/b/foo/index.ts", "/a/b/foo/index.tsx", ]); @@ -121,25 +119,17 @@ module ts { "/a/b/c/d/node_modules/foo.ts", "/a/b/c/d/node_modules/foo.tsx", "/a/b/c/d/node_modules/foo.d.ts", - "/a/b/c/d/node_modules/foo.js", - "/a/b/c/d/node_modules/foo.jsx", "/a/b/c/d/node_modules/foo/package.json", "/a/b/c/d/node_modules/foo/index.ts", "/a/b/c/d/node_modules/foo/index.tsx", "/a/b/c/d/node_modules/foo/index.d.ts", - "/a/b/c/d/node_modules/foo/index.js", - "/a/b/c/d/node_modules/foo/index.jsx", "/a/b/c/node_modules/foo.ts", "/a/b/c/node_modules/foo.tsx", "/a/b/c/node_modules/foo.d.ts", - "/a/b/c/node_modules/foo.js", - "/a/b/c/node_modules/foo.jsx", "/a/b/c/node_modules/foo/package.json", "/a/b/c/node_modules/foo/index.ts", "/a/b/c/node_modules/foo/index.tsx", "/a/b/c/node_modules/foo/index.d.ts", - "/a/b/c/node_modules/foo/index.js", - "/a/b/c/node_modules/foo/index.jsx" ]) }); @@ -161,41 +151,27 @@ module ts { "/a/node_modules/b/c/node_modules/d/node_modules/foo.ts", "/a/node_modules/b/c/node_modules/d/node_modules/foo.tsx", "/a/node_modules/b/c/node_modules/d/node_modules/foo.d.ts", - "/a/node_modules/b/c/node_modules/d/node_modules/foo.js", - "/a/node_modules/b/c/node_modules/d/node_modules/foo.jsx", "/a/node_modules/b/c/node_modules/d/node_modules/foo/package.json", "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.ts", "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.tsx", "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.d.ts", - "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.js", - "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.jsx", "/a/node_modules/b/c/node_modules/foo.ts", "/a/node_modules/b/c/node_modules/foo.tsx", "/a/node_modules/b/c/node_modules/foo.d.ts", - "/a/node_modules/b/c/node_modules/foo.js", - "/a/node_modules/b/c/node_modules/foo.jsx", "/a/node_modules/b/c/node_modules/foo/package.json", "/a/node_modules/b/c/node_modules/foo/index.ts", "/a/node_modules/b/c/node_modules/foo/index.tsx", "/a/node_modules/b/c/node_modules/foo/index.d.ts", - "/a/node_modules/b/c/node_modules/foo/index.js", - "/a/node_modules/b/c/node_modules/foo/index.jsx", "/a/node_modules/b/node_modules/foo.ts", "/a/node_modules/b/node_modules/foo.tsx", "/a/node_modules/b/node_modules/foo.d.ts", - "/a/node_modules/b/node_modules/foo.js", - "/a/node_modules/b/node_modules/foo.jsx", "/a/node_modules/b/node_modules/foo/package.json", "/a/node_modules/b/node_modules/foo/index.ts", "/a/node_modules/b/node_modules/foo/index.tsx", "/a/node_modules/b/node_modules/foo/index.d.ts", - "/a/node_modules/b/node_modules/foo/index.js", - "/a/node_modules/b/node_modules/foo/index.jsx", "/a/node_modules/foo.ts", "/a/node_modules/foo.tsx", "/a/node_modules/foo.d.ts", - "/a/node_modules/foo.js", - "/a/node_modules/foo.jsx", "/a/node_modules/foo/package.json", "/a/node_modules/foo/index.ts", "/a/node_modules/foo/index.tsx" From e630ce247b6501d7a61ff1439ed628f63ca4ca71 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 9 Nov 2015 12:49:36 -0800 Subject: [PATCH 10/10] Fix merge problems from master --- src/compiler/binder.ts | 11 +++++------ src/compiler/checker.ts | 6 +++--- src/compiler/parser.ts | 2 +- src/compiler/program.ts | 22 +++++++++++----------- src/compiler/utilities.ts | 1 - src/harness/fourslash.ts | 6 +++--- src/server/editorServices.ts | 4 ++-- tests/cases/unittests/moduleResolution.ts | 6 ++++-- tests/webTestServer.ts | 17 ----------------- 9 files changed, 29 insertions(+), 46 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 366ad799cd17d..49b259ea695b9 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1,3 +1,4 @@ +/// /// /* @internal */ @@ -109,8 +110,6 @@ namespace ts { let lastContainer: Node; let seenThisKeyword: boolean; - const isJavaScriptFile = isSourceFileJavaScript(file); - // state used by reachability checks let hasExplicitReturn: boolean; let currentReachabilityState: Reachability; @@ -1154,7 +1153,7 @@ namespace ts { case SyntaxKind.Identifier: return checkStrictModeIdentifier(node); case SyntaxKind.BinaryExpression: - if (isJavaScriptFile) { + if (isInJavaScriptFile(node)) { if (isExportsPropertyAssignment(node)) { bindExportsPropertyAssignment(node); } @@ -1229,7 +1228,7 @@ namespace ts { return bindAnonymousDeclaration(node, SymbolFlags.Function, bindingName); case SyntaxKind.CallExpression: - if (isJavaScriptFile) { + if (isInJavaScriptFile(node)) { bindCallExpression(node); } break; @@ -1275,8 +1274,8 @@ namespace ts { bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName) }"`); } - function bindExportAssignment(node: ExportAssignment|BinaryExpression) { - let boundExpression = node.kind === SyntaxKind.ExportAssignment ? (node).expression : (node).right; + function bindExportAssignment(node: ExportAssignment | BinaryExpression) { + const boundExpression = node.kind === SyntaxKind.ExportAssignment ? (node).expression : (node).right; if (!container.symbol || !container.symbol.exports) { // Export assignment in some sort of block construct bindAnonymousDeclaration(node, SymbolFlags.Alias, getDeclarationName(node)); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index caff64672fe7d..fe406c00180b9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -990,7 +990,7 @@ namespace ts { // Module names are escaped in our symbol table. However, string literal values aren't. // Escape the name in the "require(...)" clause to ensure we find the right symbol. - const moduleName = escapeIdentifier(moduleReferenceLiteral.text); + let moduleName = escapeIdentifier(moduleReferenceLiteral.text); if (moduleName === undefined) { return; @@ -3845,9 +3845,9 @@ namespace ts { } function resolveExternalModuleTypeByLiteral(name: StringLiteral) { - let moduleSym = resolveExternalModuleName(name, name); + const moduleSym = resolveExternalModuleName(name, name); if (moduleSym) { - let resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); + const resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); if (resolvedModuleSymbol) { return getTypeOfSymbol(resolvedModuleSymbol); } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 894aa13cd05d7..5c57bfb550190 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1,5 +1,5 @@ -/// /// +/// namespace ts { const nodeConstructors = new Array Node>(SyntaxKind.Count); diff --git a/src/compiler/program.ts b/src/compiler/program.ts index b38ffb03859b1..496dcbd0d7ce0 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -53,13 +53,13 @@ namespace ts { if (getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { const failedLookupLocations: string[] = []; const candidate = normalizePath(combinePaths(containingDirectory, moduleName)); - let resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host); + let resolvedFileName = loadNodeModuleFromFile(supportedJsExtensions, candidate, failedLookupLocations, host); if (resolvedFileName) { return { resolvedModule: { resolvedFileName }, failedLookupLocations }; } - resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); + resolvedFileName = loadNodeModuleFromDirectory(supportedJsExtensions, candidate, failedLookupLocations, host); return resolvedFileName ? { resolvedModule: { resolvedFileName }, failedLookupLocations } : { resolvedModule: undefined, failedLookupLocations }; @@ -69,8 +69,8 @@ namespace ts { } } - function loadNodeModuleFromFile(candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string { - return forEach(supportedExtensions, tryLoad); + function loadNodeModuleFromFile(extensions: string[], candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string { + return forEach(extensions, tryLoad); function tryLoad(ext: string): string { const fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext; @@ -84,7 +84,7 @@ namespace ts { } } - function loadNodeModuleFromDirectory(candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string { + function loadNodeModuleFromDirectory(extensions: string[], candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string { const packageJsonPath = combinePaths(candidate, "package.json"); if (host.fileExists(packageJsonPath)) { @@ -100,7 +100,7 @@ namespace ts { } if (jsonContent.typings) { - const result = loadNodeModuleFromFile(normalizePath(combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); + const result = loadNodeModuleFromFile(extensions, normalizePath(combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); if (result) { return result; } @@ -111,7 +111,7 @@ namespace ts { failedLookupLocation.push(packageJsonPath); } - return loadNodeModuleFromFile(combinePaths(candidate, "index"), failedLookupLocation, host); + return loadNodeModuleFromFile(extensions, combinePaths(candidate, "index"), failedLookupLocation, host); } function loadModuleFromNodeModules(moduleName: string, directory: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations { @@ -122,12 +122,12 @@ namespace ts { if (baseName !== "node_modules") { const nodeModulesFolder = combinePaths(directory, "node_modules"); const candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName)); - let result = loadNodeModuleFromFile(candidate, failedLookupLocations, host); + let result = loadNodeModuleFromFile(supportedExtensions, candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations }; } - result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); + result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations }; } @@ -162,7 +162,7 @@ namespace ts { const failedLookupLocations: string[] = []; let referencedSourceFile: string; - let extensions = compilerOptions.allowNonTsExtensions ? supportedJsExtensions : supportedExtensions; + const extensions = compilerOptions.allowNonTsExtensions ? supportedJsExtensions : supportedExtensions; while (true) { searchName = normalizePath(combinePaths(searchPath, moduleName)); referencedSourceFile = forEach(extensions, extension => { @@ -689,7 +689,7 @@ namespace ts { return; } - let isJavaScriptFile = isSourceFileJavaScript(file); + const isJavaScriptFile = isSourceFileJavaScript(file); let imports: LiteralExpression[]; for (const node of file.statements) { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 956cebc8a24d4..a1f649f3cf894 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1,4 +1,3 @@ -/// /// /* @internal */ diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 4aa3a371b6d4c..1c8593a9e1294 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -224,8 +224,8 @@ namespace FourSlash { // Add input file which has matched file name with the given reference-file path. // This is necessary when resolveReference flag is specified private addMatchedInputFile(referenceFilePath: string, extensions: string[]) { - let inputFiles = this.inputFiles; - let languageServiceAdapterHost = this.languageServiceAdapterHost; + const inputFiles = this.inputFiles; + const languageServiceAdapterHost = this.languageServiceAdapterHost; if (!extensions) { tryAdd(referenceFilePath); } @@ -234,7 +234,7 @@ namespace FourSlash { } function tryAdd(path: string) { - let inputFile = inputFiles[path]; + const inputFile = inputFiles[path]; if (inputFile && !Harness.isLibraryFile(path)) { languageServiceAdapterHost.addScript(path, inputFile); return true; diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index fb7a221b12485..333cea2745d6f 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -371,7 +371,7 @@ namespace ts.server { openRefCount = 0; constructor(public projectService: ProjectService, public projectOptions?: ProjectOptions) { - if(projectOptions && projectOptions.files){ + if (projectOptions && projectOptions.files) { // If files are listed explicitly, allow all extensions projectOptions.compilerOptions.allowNonTsExtensions = true; } @@ -1321,7 +1321,7 @@ namespace ts.server { this.setCompilerOptions(opt); } else { - var defaultOpts = ts.getDefaultCompilerOptions(); + const defaultOpts = ts.getDefaultCompilerOptions(); defaultOpts.allowNonTsExtensions = true; this.setCompilerOptions(defaultOpts); } diff --git a/tests/cases/unittests/moduleResolution.ts b/tests/cases/unittests/moduleResolution.ts index 096f991401971..c53cad5725abc 100644 --- a/tests/cases/unittests/moduleResolution.ts +++ b/tests/cases/unittests/moduleResolution.ts @@ -95,8 +95,8 @@ module ts { let resolution = nodeModuleNameResolver(moduleName, containingFile.name, createModuleResolutionHost(containingFile, packageJson, moduleFile)); assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name); assert.equal(!!resolution.resolvedModule.isExternalLibraryImport, false); - // expect three failed lookup location - attempt to load module as file with all supported extensions - assert.equal(resolution.failedLookupLocations.length, 3); + // expect five failed lookup location - attempt to load module as file with all supported extensions + assert.equal(resolution.failedLookupLocations.length, 5); } it("module name as directory - load from typings", () => { @@ -117,6 +117,8 @@ module ts { "/a/b/foo.ts", "/a/b/foo.tsx", "/a/b/foo.d.ts", + "/a/b/foo.js", + "/a/b/foo.jsx", "/a/b/foo/index.ts", "/a/b/foo/index.tsx", ]); diff --git a/tests/webTestServer.ts b/tests/webTestServer.ts index ad9316ed04fc6..6bd15359e3f6b 100644 --- a/tests/webTestServer.ts +++ b/tests/webTestServer.ts @@ -263,21 +263,6 @@ http.createServer(function (req: http.ServerRequest, res: http.ServerResponse) { var browserPath: string; if ((browser && browser === 'chrome')) { -<<<<<<< HEAD - const platform = os.platform(); - let defaultChromePath: string; - switch(platform) { - case "win32": - defaultChromePath = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"; - break; - case "linux": - defaultChromePath = "/opt/google/chrome/chrome"; - break; - default: - console.log(`Default Chrome location for platform ${platform} is unknown`); - break; - } -======= let defaultChromePath = ""; switch (os.platform()) { case "win32": @@ -291,8 +276,6 @@ if ((browser && browser === 'chrome')) { console.log(`default Chrome location is unknown for platform '${os.platform()}'`); break; } - ->>>>>>> master if (fs.existsSync(defaultChromePath)) { browserPath = defaultChromePath; } else {